By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,454 Members | 3,103 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,454 IT Pros & Developers. It's quick & easy.

AUTOMATE EMAIL ADDRESS IN ACCESS?

P: n/a

I have an email macro setup (maybe I should go another way, but that
was the quickest at the moment...) and what I would like to do is
automate the "to" addressee of the email it generates for sending.

What I have is an email button that creates a report based on a
property address on a form (driven by a query which has criteria such
as forms!frmPROPERTY!address). That open form also has an email
address on it for the owner, and I would like that very same button to
also reference the email address on the form and automatically populate
the email when it opens (Outlook). Within the Access macro, I can
stipulate the subject line and the text and that works fine. How can I
get it to also reference the email address on the form?

Scott Baird

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Check this out.

http://www.peterssoftware.com/c_emfa.htm

Nov 13 '05 #2

P: n/a
Thanks, but not quite what I'm looking for. This allows me to send TO
the same person each time. In my scenario, each record has it's own
email address (one property, name, phone, email address, is on the
screen at a time). I need to be able to send to various email
addresses (whichever one is on the screen at the time) with a push of a
button.

I can declare my subject line. I can even declare a few lines of text.
How can I declare the desired email address based on the contact
person's email addy?

Nov 13 '05 #3

P: n/a
> Thanks, but not quite what I'm looking for. This allows me to send TO
the same person each time. In my scenario, each record has it's own
email address (one property, name, phone, email address, is on the
screen at a time). I need to be able to send to various email
addresses (whichever one is on the screen at the time) with a push of a
button.

I can declare my subject line. I can even declare a few lines of text.
How can I declare the desired email address based on the contact
person's email addy?


The routine below is in a database where each record has a subform datasheet
with a list of associated email addresses. Users can enter a comment after
each email address if desired like this:

so*********@somedomain.com # this is Joe's home email address

double-clicking on the email address in the datasheet opens and addresses an
email to that address. With a little code you can extend this to do other
things. A good site for reference is http://www.slipstick.com/

Private Sub E_mail_Addresses_DblClick(Cancel As Integer)
'Required reference: Microsoft Outlook 11.0 Object Library
On Error GoTo HandleErr
Dim strEmail As String
Dim olapp As Outlook.Application
Dim olmi As Outlook.MailItem
Dim j As String
Set olapp = GetObject(, "Outlook.Application")
strEmail = Me![E-mail Addresses]
j = InStr(1, strEmail, "#", 1)
If j Then strEmail = Trim$(Left(strEmail, j - 1))
Set olmi = olapp.CreateItem(olMailItem)
olmi.Recipients.Add strEmail
olmi.display
Exit_Here:
On Error Resume Next
Set olmi = Nothing
Set olapp = Nothing
Exit Sub
HandleErr:
Select Case Err.Number
Case 94 'Invalid use of Null
'(when double clicking on blank field)
Case 287
Case 429
'if the mail item we are creating is sent, it will not leave
'the outbox unless Outlook is open. To make sure messages
'are sent immedaitely, outlook is opened here if it is
'not already open.
Call Shell(modOffice.GetOutlookPath)
Set olapp = New Outlook.Application
Resume Next
Case Else
modHandler.LogErr "frm0Email", "E_mail_Addresses_DblClick"
End Select
Resume Exit_Here
End Sub
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.