I have designed a sendmail function which I'm really happy with. It does exactly what I need to do. However I am having some problems trying to add attachments to it. I have looked at many different examples using CDO, objMessage and .Add.Attachments but can't work out how I would integrate these into my code. Could someone take a quick look at the code and let me know what would be the best way for me to add attachments???
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSubject As String
Dim strEmailAddress As String
Dim strEMailMsg As String
Dim ingCounter As Integer
Dim intCount As Integer
' Write messagebox content to a file
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.CreateTextFile("C:\Email.htm", vbTrue)
theFile.WriteLine "<BODY style='font-family:Century Gothic;'>"
theFile.WriteLine "<br />"
' Append the user's signature file
theFile.WriteLine fso.OpenTextFile("K:\Admin & office\logo & letterhead\email-signature.html").ReadAll
' Close the file which now contains the email body and signature and read the content into myHTML
Set f = fso.OpenTextFile("C:\Email.htm", 1)
MyHTML = f.ReadAll
strSubject = [Subject]
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qryEmailOut")
Do Until rst.EOF
strEmailAddress = rst![email address]
strEMailMsg = MyHTML
'EMAIL USER DETAILS & ATT REPORT
DoCmd.SendObject , , acFormatRTF, strEmailAddress, _
, , strSubject, strEMailMsg, False, False
Set rst = Nothing
Set dbs = Nothing
I was hoping at some point to have a preview of the e-mail before sending which is why I have written to an external file. My theory being that I could then load up email.htm before sending it. I'm not actually sure how I'm going to do this yet so if you have any ideas please let me know.