DoCmd.SendObject Code error help please! (1 Viewer)

GeorgieK

New member
Local time
Today, 12:38
Joined
May 28, 2021
Messages
5
Hi

I've written the code below to send an automatically populated email. Access is telling me there is a syntax error with this code. I cannot find out what it is!

Code:
 DoCmd.SendObject , "", "", "[email]xxx@xxx.com[/email]", "", "", & Me.Document_Name & & Me.Document_Number& & Me.Version_Number&, "Dear all " & vbLf & vbLf & "Please note that there is a new version of the above document." & vbLf & vbLf & "Please ensure that you familiarise yourself with this new version and delete all previous copies. Below is a summary of the changes made." & vbLf & vbLf & ""&Me.Reason_for_change&"" & vbLf & vbLf & "Thank you", True

This is linked to a document register where someone has created a new version of a document and I want them to be able to send an email to an email address that forwards emails to all staff to let them know of the new version.

If you are able to help me with the above I would be very grateful. I've been trying to work out what is wrong for weeks!

Many thanks

Georgie
 
Last edited by a moderator:

Minty

AWF VIP
Local time
Today, 12:38
Joined
Jul 26, 2013
Messages
10,368
Try this - I've moved the message text into a separate string variable to make it easier to see and debug.

Code:
    Dim sMessage As String
    Dim sSubject as String
    
    sMessage = "Dear all " & vbLf & vbLf & "Please note that there is a new version of the above document." & vbLf & vbLf & "Please ensure that you familiarise yourself with this new version and delete all previous copies. Below is a summary of the changes made." & vbLf & vbLf & Me.Reason_for_change & vbLf & vbLf & "Thank you"
    sSubject = Me.Document_Name & Me.Document_Number & Me.Version_Number
    DoCmd.SendObject acSendNoObject, , acFormatHTML, "xxx@xxx.com", , , sSubject, sMessage, True
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:38
Joined
May 7, 2009
Messages
19,233
or simply:

Code:
docmd.SendObject ,,, "xxx@xxx.com",,, Me.Document_Name & Me.Document_Number & Me.Version_Number, "Dear all " & vbLf & vbLf & "Please note that there is a new version of the above document." & vbLf & vbLf & "Please ensure that you familiarise yourself with this new version and delete all previous copies. Below is a summary of the changes made." & vbLf & vbLf & Me.Reason_for_change & vbLf & vbLf & "Thank you", True
 

GeorgieK

New member
Local time
Today, 12:38
Joined
May 28, 2021
Messages
5
Thanks so much. It didn't work at first, but when I put the speech marks around the email address it worked. Very pleased with it. Thanks so much. Georgie x
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:38
Joined
Sep 21, 2011
Messages
14,234
Thanks so much. It didn't work at first, but when I put the speech marks around the email address it worked. Very pleased with it. Thanks so much. Georgie x
You had quote marks around the email address in the first post?
"xxx@xxx.com"
 

GeorgieK

New member
Local time
Today, 12:38
Joined
May 28, 2021
Messages
5
Yes you are right. I noticed that they were there in your reply after I typed that thank you this morning too. I must have deleted them when i typed in the proper email and then realised after that they were missing so added them back in. If that makes any sense! Anyway, thanks again.
 

GeorgieK

New member
Local time
Today, 12:38
Joined
May 28, 2021
Messages
5
Sorry about not using the code tags in my original post too. New to this site.
 

Users who are viewing this thread

Top Bottom