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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SEND FROM SENDOBJECT VIA QUERY 1

Status
Not open for further replies.

barry2004

Technical User
Oct 13, 2004
42
GB
Hi guys, i have 2 queries "sendpromomail" & "sendpromotxt" which select either the email addresses or cellular numbers of customers from a particular table only. I would like to create a SendObject macro or something similar which would take the numbers or email addresses from either queries and then send to the recipients all in one go.
 
Hi
I think you might be best using Outlook for this, if that is an option. SendObject sends things as attachments. You could loop through your table and create an email message for each person. Is this the direction you want to go?
 
Hi Remou, i have a software (part of Outlook 2003, called eSMS executive) which can send SMS text messages. I need Access to know that the SendObject or whatever module for the cellular numbers has to Output to this application to all the recipients from the query. The cellular numbers are more of a priority for me than the email addresses...
 
Hi
I think that SMS is like email, only with numbers. For example, 1234567890@mobile.att.net. If this is correct, something like the code below might work. I have not got Outlook 2003, so you will probably get better information of someone else, however, it might give you a few ideas :)
Code:
Dim rs as Recordset
Dim strEmail, strSubject As String, strBody As String
Dim objOutlook As outlook.Application
Dim objEmail As outlook.MailItem

Set rs = CurrentDB.OpenRecordset("Select Email, SMS From MyTable")
Set objOutlook = CreateObject("Outlook.application")

Do While Not rs.EOF
  Set objEmail = objOutlook.CreateItem(olMailItem)
  If Trim(rs!SMS) & "" <> "" Then
     strEmail = rs!SMS
  Else
     strEmail = rs!Email
  End If

  strBody = "This is body text"
  strSubject = "Subject"
  With objEmail
    .To = strEmail
    .Subject = strSubject
    .Body = strBody
    .Send 'Will cause warning message
  End With
  Set objEmail = Nothing
Loop
 
Thanks dude, though it doesn't seem to like:

Dim objOutlook As outlook.Application

in your expression....
 
Hi
You will need a reference to the Oulook Library. [blush]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top