Is it possible to "personalize" when sending e-mail from access??

  • Thread starter Thread starter Earl.AKA J.Alladien in access forum!!
  • Start date Start date
E

Earl.AKA J.Alladien in access forum!!

Hi all,

I am working with following code from Arvin Meyer to send out e-mails from
my db:

SEND = -1
'Arvin Meyer 03/12/1999
'Updated 7/21/2001
On Error GoTo Error_Handler

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
.To = Forms![Names1]![E-mail Address]
.Subject = Forms![Names1]![SUB]
.Body = Forms![Names1]![Body]
.SEND
'.ReadReceiptRequested
End With

Exit_Here:
Set objOutlook = Nothing
Exit Sub

Error_Handler:
MsgBox Err & ": " & Err.Description
Resume Exit_Here


The table this form is based on also contains the peoples names all the
adresses belong to;is it possible to adress each person personally like when
you would use MERGE MAIL fe:

Dear John White,

Pls see following etc etce.........

Dear harold White,

Pls see following etc etce.........

Dear jennfier Aniston,

Pls see following etc etce.........

Thanks in advance!
 
I'm working on a small project to build email template functionality, about
2/3 done.

I can give you the gist of how I got it to work:
- let the user create email templates (stored in a table with the normal
fields to, from, cc, bcc, subject, body etc...)
- use tokens that determine where data will be substituted
To: ##Email##
From: (e-mail address removed)
Subject: Info
Dear ##Firstname##,

Thanks for you interest.

We have this information on file:
##CompanyName##
##FirstName## ##MI## ##LastName##
##Address##

Thanks,
Mark

- at runtime you pass SQL to a routine that runs through the fields in the
recordset and substitutes
- I prefer to use a third party smtp component for sending the mail but the
way you have shown will work (if you have Outlook)

I have a few more things planned, email history, html emails, etc...

Shoot me an email if you are interested, we could discuss more,
Mark
RPT Software
http://www.rptsoftware.com



"Earl.AKA J.Alladien in access forum!!"
 
If you have a field in the table with the email addresses that stores the
name of each person, then you need to capture their name as part of the body
of the message. Change your .Body line to this:

..Body = "Dear " & Dlookup("[NameOfPerson]","[NameOfTable]","[EmailAddress] =
'" & Forms!Names1.[E-mail Address] & "') & ";" & vbNewLine & vbNewLine &
Forms!Names1.Body

Change NameOfTable to the table that the email addresses and names are
stored in, NameOfPerson to the field name in that table that contains the
names of the people you're addressing, and EmailAddress to the field name in
that table that stores the email addresses. What this will do is look at your
form for the [E-mail Address], search for that email address in the table,
and return the name associated with that email address. You will have to make
sure your form doesn't contain the salutation line anymore as well.


HTH,

Nicholas Scarpinato
 
Mark;

I have always wanted to know more about your software.

Good to see you on these newsgroups!

-Aaron


I'm working on a small project to build email template functionality, about
2/3 done.

I can give you the gist of how I got it to work:
- let the user create email templates (stored in a table with the normal
fields to, from, cc, bcc, subject, body etc...)
- use tokens that determine where data will be substituted
To: ##Email##
From: (e-mail address removed)
Subject: Info
Dear ##Firstname##,

Thanks for you interest.

We have this information on file:
##CompanyName##
##FirstName## ##MI## ##LastName##
##Address##

Thanks,
Mark

- at runtime you pass SQL to a routine that runs through the fields in the
recordset and substitutes
- I prefer to use a third party smtp component for sending the mail but the
way you have shown will work (if you have Outlook)

I have a few more things planned, email history, html emails, etc...

Shoot me an email if you are interested, we could discuss more,
Mark
RPT Softwarehttp://www.rptsoftware.com


I am working with following code from Arvin Meyer to send out e-mails from
my db:
SEND = -1
'Arvin Meyer 03/12/1999
'Updated 7/21/2001
On Error GoTo Error_Handler
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
   .To = Forms![Names1]![E-mail Address]
   .Subject = Forms![Names1]![SUB]
   .Body = Forms![Names1]![Body]
   .SEND
   '.ReadReceiptRequested
End With
Exit_Here:
   Set objOutlook = Nothing
   Exit Sub
Error_Handler:
   MsgBox Err & ": " & Err.Description
   Resume Exit_Here
The table this form is based on also contains the peoples names all the
adresses belong to;is it possible to adress each person personally like
when
you would use MERGE MAIL fe:
Dear John White,
Pls see following  etc etce.........
Dear harold White,
Pls see following  etc etce.........
Dear jennfier Aniston,
Pls see following  etc etce.........
Thanks in advance!
 
Back
Top