Hi, I am wondering if it is possible to send an email using CDO where I can add a field from my form to the Subject or textbody of the email message?
This is the code I am currently using, it works great but I want to add some information to the email regarding the record from which the email was sent.
Public Function send_email_PO()
Set cdomsg = CreateObject("CDO.message")
With cdomsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "blablabla"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*****"
.Update
End With
' build email parts
With cdomsg
.To = "email@here" .From = "email@here"
.Subject = "Record Updated"
.TextBody = "This is an automatically generated email, please do not reply because no one will see it and you will be left wondering why you are not getting a response. ***"
.Send
End With
Set cdomsg = Nothing
End Function
This is the code I am currently using, it works great but I want to add some information to the email regarding the record from which the email was sent.
Public Function send_email_PO()
Set cdomsg = CreateObject("CDO.message")
With cdomsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "blablabla"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*****"
.Update
End With
' build email parts
With cdomsg
.To = "email@here" .From = "email@here"
.Subject = "Record Updated"
.TextBody = "This is an automatically generated email, please do not reply because no one will see it and you will be left wondering why you are not getting a response. ***"
.Send
End With
Set cdomsg = Nothing
End Function