Send object method

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

Guest

I have received advice regarding this action before, but still have not got
it quite down.
I will have a form (Recruit Data) where a user will input all relevant data
about a new recruit, including their email and their manager's email. They
will then click a button (add data macro) that will store it in a table.
Now, after 30 days with our firm, I want the user to be able to click on a
send email button and automatically have the action look to the fields that
were previously populated on the Recruit Data form to insert the email
addresses in the correct fields of the email (To, CC) I would also like the
body of the email to be mainly static, but have spots where the recruits
first name, which will vary, is inserted (ex. John in xy branch needs to
speak with you one on one; Kelly in xy branch needs to speak with you one on
one). Is there a way to reference the controls on the Recruit Data form that
contain the email addresses I want to send to as well as reference the first
name control throughout the body of the email? If I need to be more clear
about anything please let me know. Also, explaining in lehman's terms would
be best as I am new to development using VBA.

Thank you all,
MS
 
First things first. If you are looking to use the sendobject method to do
this the basic synthax is

expression.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc,
Subject, MessageText, EditMessage, TemplateFile)

Therefore, based on your post you will need to populate the 4th,5th,7th &
8th input variables.

Docmd.SendObject
,,,"(e-mail address removed)","(e-mail address removed)",,"Subject","Body
Content"

The code above is what we need to achieve, now it is just a question of
using the controls on your form to populate the variable instead of hard
coding it. Now you did not give the names of the controls on your form, so
you may have to change the names I use in the following code to match with
your naming convention, but here is the basic idea.

Using the button's OnClick event the following code should do the job.

Dim strMessage as String
Dim strSubject as String

strSubject= "Your Subject Heading Should Go Here"
strMessage = Me.EmployeeName & " in " & Me.BranchNumber & " branch needs to
speak with you one on one."

Docmd.SendObject ,,,Me.TOControlName,Me.CCControlName,,strSubject,strMessage

Assuming you have a control on your form named TOControlName which has the
e-mail address to be used for the To fields and CCControlName to be used for
the CC field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top