Hi all,
I have lots of working ideas from the interweb about how to send emails using gmail, but I cannot crack the addattachment part.
No matter what variations I use, I cannot attach a zip file from a specific location, which is defined in [Me.Attachment], a field on my 'code-executing' form.
The code below has been edited for security and privacy purposes, but trust me, when I put the correct email addresses and password in, the code works apart from the attachment!
Anybody got any help please?
Code:Dim strMailto As String strMailto = "someone@somewhere.com" Dim strMailFrom As String strMailFrom = "me@somewhere.com" Dim strSubject As String strSubject = "My Subject from - " & DtSite Dim StrBody As String StrBody = "Please find attached the latest subject matter. Thank you" & vbCrLf & "Please do not reply to this email." Dim msg As Object Set msg = CreateObject("CDO.Message") msg.FROM = strMailFrom msg.To = strMailto msg.Subject = strSubject msg.TextBody = StrBody msg.replyto = strMailFrom If IsNull(Me.Attachment) = False Then Dim strAttachment As String strAttachment = Me.Attachment msg.addattachment "file://" & strAttachment & "" End If msg.configuration.Fields("http://schemas.microsoft.com/cdo/con...ion/smtpserver") = "smtp.gmail.com" msg.configuration.Fields("http://schemas.microsoft.com/cdo/con...smtpserverport") = 465 msg.configuration.Fields("http://schemas.microsoft.com/cdo/con...tion/sendusing") = 2 msg.configuration.Fields.Item("http://schemas.microsoft.com/cdo/con...n/sendusername") = "someone@gmail.com" msg.configuration.Fields.Item("http://schemas.microsoft.com/cdo/con...n/sendpassword") = "password" msg.configuration.Fields.Item("http://schemas.microsoft.com/cdo/con...ion/smtpusessl") = True msg.configuration.Fields.Item("http://schemas.microsoft.com/cdo/con...tpauthenticate") = 1 msg.configuration.Fields.Update msg.Send