Sending an email with a text file attached, this works (test email is received):
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "[email protected]"
emailObj.To = "[email protected]"
emailObj.Subject = "File attached"
emailObj.TextBody = "Please have a look at the attached file. Thanks."
emailObj.AddAttachment "d:\temp\test.txt"
Set emailConfig = emailObj.Configuration
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server.webhost.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "top_secret"
emailConfig.Fields.Update
emailObj.Send
If err.number = 0 then Msgbox "Your file has been sent. Someone will respond as soon as possible."
But when I try to send a binary file, this does NOT work (test email message is not received):
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "[email protected]"
emailObj.To = "[email protected]"
emailObj.Subject = "File attached"
emailObj.TextBody = "Please have a look at the attached file. Thanks."
emailObj.AddAttachment "d:\temp\test.rtf"
Set emailConfig = emailObj.Configuration
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server.webhost.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "top_secret"
emailConfig.Fields.Update
emailObj.Send
If err.number = 0 then Msgbox "Your file has been sent. Someone will respond as soon as possible."
What do I need to add/change to be able to attach a binary file?