Email

MarkP

Registered User.
Local time
Today, 19:18
Joined
Jun 13, 2003
Messages
15
Is thier any way to send out a mass email using email address's from the results of an access database query?
 
MarkP said:
Is thier any way to send out a mass email using email address's from the results of an access database query?

Of course...do a search on the forum.

Code:
Dim db as Database
Dim rs as Recordset

Set db=Currentdb
Set rs=db.OpenRecordset("qryEmail")

if rs.bof then
  'no records in query
else
         Set EmailApp = CreateObject("Outlook.Application")    'using    the outlook object
Set NameSpace = EmailApp.GetNamespace("MAPI")

   while not rs.eof
         'use the outlook object model here...again do a search on the forum 
    Set EmailSend = EmailApp.CreateItem(0)
    EmailSend.Subject="Blah"
    EmailSend.Body = "blah"
    EmailSend.Recipients.Add(rs("UserEmail").Value)
    EmailSend.Send
    Set EmailSend=Nothing
    rs.MoveNext
   wend
end if

Set EmailSend=Nothing
Set rs=nothing
set db=nothing

You can even send outlook tasks by passing the value 3 to CreateItem rather than 0. With tasks make sure you apply .Assign to assign the task after you have added the reciepient.

Jon
 
That worked as far as sending the email but I am still having two problems with it. 1st I can not get it to include the person's name in the body which is another feild in the database. 2nd It will only let me send one line of text in the body of the letter. Is thier any way that I can extend the body of the letter to be a full size letter using several of the feilds in th database in different places?
 
Just use the recordset and reference the fields in the email:

EmailSend.Body = "Hello: " & RS("YourUserField").Value & ", my name is blah blah...I used to live at: " & RS("YourAddress").Value & vbCrLf & " I loved it!"

EmailSend.Body = EmailSend.Body & vbCrlf & vbCrlf & "Sincerely, " & Rs("MEField").Value

...
Etc...etc...real simple
 
Dim db as Database
Dim rs as Recordset

I would advise using:

Dim db as DAO.Database
Dim rs as DAO.Recordset

Upward compatible and such....

Regards
 
namliam said:
Dim db as Database
Dim rs as Recordset

I would advise using:

Dim db as DAO.Database
Dim rs as DAO.Recordset

Upward compatible and such....

Regards

If DAO is what he/she has referenced you don't need to add DAO.
I still wonder if he / she understood how to put variables into the body of the email.
 
When I do this I get a message that says a program is trying to access an email address you have stored in outlook do you wish to allow this. And then I have to click yes for every single e-mail. I tried the allow acces for 10 minutes but it still makes me click yes. I am trying to send over 700 emails so this is not a realistic way to do it. Is thier a way to get around this?
 
Try searching for Remdemption (and my name) i posted a link somewhere on the forum...

I tried the allow acces for 10 minutes
You tried the what? Please elaborate...

Alternatively you might try building a send list sending the mail to more than 1 person at a time limiting the number of mails going out....

Regards
 

Users who are viewing this thread

Back
Top Bottom