Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email to Mulitiple email addresses through Access 1

Status
Not open for further replies.

nim180

IS-IT--Management
Aug 11, 2005
161
AU
Hey Everyone,

I have a continuous form with a combobox called 'Groups' in the header. It has a number of text boxes on the detail section of the form. From the combobox the user can choose from 'Foreman', 'Worker', Ex-Worker' and 'Client. Depending on what is chosen in the combobox, the textboxes are populated.

One of the textboxes is called 'Email', if the user chooses 'Foreman' from the combobox, it populates the list with 20 different email addresses.

What I would like to do is have a command button when clicked will take all the email addresses related to 'Foreman' and make an instance of outlook containing all the relevant addresses to send a group email? How can I go about doing this.

Thanks,
Nim
 
Have you tried the DoCmd.SendObject method ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hey PHV,

Yes, I've tried the DoCmd.SendObject method but it only takes the email address from the first field! Any Suggestions on how I could retrieve all the email addresses.

Thanks,
Nim
 
So, what is your actual code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry PHV, I should have posted that in my previous comment. I was following the FAQ faq702-4509. My code is as follows.

Private Sub BtnEmail_Click()

On Error Resume Next

Dim strToWhom As String
Dim strMsgBody As String
Dim strTitle As String

strToWhom = Me!Email
strMsgBody = Me!Body
strTitle = Me!Title

DoCmd.SendObject , , , strToWhom, , , strTitle, strMsgBody, True

End Sub

As its a countinuous form, I'm guessing Me!Email is not going to work to grab all the required email addresses!

Thanks,
Nim

 
Replace this:
strToWhom = Me!Email
with this:
Code:
With Me.Recordset
  .MoveFirst
  While Not .EOF
    strToWhom = strToWhom & ";" & Me!Email
    .MoveNext
  WEnd
  strToWhom = Mid(strToWhom, 2)
End With

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV, that worked well. I noticed that if i do not want to send the email and close the instances of outlook I get a run-time error 2501, "The sendObject action was cancelled". Is there anyway of preventing this from poping up.

Thanks,
nim
 
I get a run-time error 2501
Even with an error handler routine ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry PHV, I had the Error Handler commented out for some reason. Thanks for your help :)

nim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top