TO Daniel...send object method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Thanks for all the follow up so far, I had to shelve the project I was
working on for a bit but am back at it now...please see below the code that I
entered for the send object method.

Private Sub Ctl15DayEmailBTA_Click()

Dim strMessage As String
Dim strSubject As String

strSubject = "New Recruit Approaching 15 Day BTA Meeting"
strMessage = Me.Recruit_Name & "in the" & Me.RecruitBranch & "branch is
approaching his 15 day anniversary of employment."

DoCmd.SendObject(,,,Me.Recruitemail,Me.EmailBOM;
Me.BTA_Email,,strsubject,strMessage)

End Sub

The Text boxes I am referring to on the form are labeled Recruit_Name,
RecruitBranch, Recruitemail, EmailBOM, and BTA_Email. However, when I go to
run it I get the compile error: syntax error message then it highlights in
red the DoCmd.sendobject line...do you see a problem with the code I am
missing and can you explain the error please.

Thank you.
 
First of all, you have used a semi-colon instead of a comma...

The SendObject method has the following parameters:
SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject,
MessageText, EditMessage, TemplateFile)

So you can see where to put the appropriate paramaters in the method.

What is EmailBOM and BTA_Email?
If they are additional email addresses, combine them in a string (separated
by semi-colons) then supply that string to the Cc or Bcc parameter.

Something like this:

strCC = Me.EmailBOM & "; " & Me.BTA_Email

DoCmd.SendObject(,,,Me.Recruitemail,strCC,,strsubject,strMessage)

If you want to display the email before sending it:
DoCmd.SendObject(,,,Me.Recruitemail,strCC,,strsubject,strMessage,True)

Steve
 
I am still receiving the Compile Error: Syntax Error. here is the new code
based on your recommendations.

Private Sub Ctl15DayEmailBTA_Click()

Dim strMessage As String
Dim strSubject As String

strSubject = "New Recruit Approaching 15 Day BTA Meeting"
strMessage = Me.Recruit_Name & "in the" & Me.RecruitBranch & "branch is
approaching his 15 day anniversary of employment.
strCC = Me.EmailBOM & ";" & Me.BTA_Email

DoCmd.SendObject(,,,Me.Recruitemail,strCC,,strSubject,strMessage,True)

End Sub

All the controls referenced are text boxes and all are email addresses. The
only thing that is not an email address is the strMessage referring to the
text box control with the recruits name in it and the branch office they work
at. Please advise insights when available. Thanks again for the help.

MS
 
I noticed that some text is missing quotes and the SendObject is written so
as to be assign to a variable rather than execute on its own. Try

Private Sub Ctl15DayEmailBTA_Click()

Dim strMessage As String
Dim strSubject As String

strSubject = "New Recruit Approaching 15 Day BTA Meeting"
strMessage = Me.Recruit_Name & "in the" & Me.RecruitBranch & "branch is " & _
"approaching his 15 day anniversary of employment."
strCC = Me.EmailBOM & ";" & Me.BTA_Email

DoCmd.SendObject , , , Me.Recruitemail, strCC, , strSubject, strMessage, True

End Sub

--
Hope this helps,

Daniel P
 
The variable was the issue, how does removing the parenthesis differ from
having them there in order of executing the command? Just for my own
knowledge if you don't mind...thanks for all the help throughout this one.
 
I can't explain the why's, but here is the way you need to work.

when assign a command to a variable, you need parenthesis
a=application.followhyperlink("http://www.msn.ca")

when directly running the command you do not
application.followhyperlink "http://www.msn.ca"

Just keep this in mind when programing. Variable=(), otherwise none.
--
Hope this helps,

Daniel P
 
Back
Top