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

sending email using ms access

Status
Not open for further replies.

tjs

IS-IT--Management
May 12, 2000
1
US
i have a database that has customer information in it.<br>one of the fields is the customer's email address.&nbsp;&nbsp;when i locate a customer's record, i want to be able to click on the email address and have outlook express or outlook come up with that customer's email address in the &quot;to:&quot; field so i can send an email.&nbsp;&nbsp;i worked a little with hyperlink, but its not doing what i want it to do, i can go in and edit the hyperlink and add email addresses, then if i click on an email address for a customer, outlook will come up, but thats the only way outlook will come up is if i have an email address in&nbsp;&nbsp;the recently used email address section.&nbsp;&nbsp;i want to be able to add a customer email address, and then when you look at that record be able to click on the email address and up pops outlook with that email address
 
I am assuming that you have a form that you are using to look at customer's records.&nbsp;&nbsp;If not, you need one, because you need to respond to a Click event.&nbsp;&nbsp;I would recommend using a button instead of clicking on the field, but that's up to you.<br><br>You will be using Automation to do this.&nbsp;&nbsp;You need to open any code window and go to Tools...References and set a reference to the Outlook Library.<br><br>This is code I wrote to do what you want, with some modifications.<br><br>****Put this code in a Click event procedure****<br>On Error GoTo DriverErr<br><br>Dim outApp As Outlook.Application<br>Dim outMessage As Outlook.MailItem<br>Dim dtmDelay As Date<br>Dim strName As String<br>Dim x As Integer<br>Dim blnErrors As Boolean<br>Dim strErrStr As String<br><br>Set outApp = CreateObject(&quot;Outlook.application&quot;)<br><br>Set outMessage = outApp.CreateItem(olMailItem)<br><br>outMessage.To = Your Field Name here<br>outMessage.Subject = Your message here<br><br>'If you want to send it, use this<br>outMessage.Send<br><br>DriverExit:<br>On Error Resume Next<br>Set outMessage = Nothing<br>outApp.Quit<br>Set outApp = Nothing<br>Exit Function<br><br>DriverErr:<br>&nbsp;&nbsp;&nbsp;&nbsp;blnErrors = True<br>&nbsp;&nbsp;&nbsp;&nbsp;strErrStr = &quot;Driver: &quot; & strName & &quot;did not print&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;Call Write_Err(&quot;GL1XX&quot;, strErrStr)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Resume DriverExit<br>***End of Code***<br><br>Let me know if you need more help.<br><br>Kathryn
 
It seems to me there's a much easier way to do this.&nbsp;&nbsp;Have your on-click event do the following:<br><br>Docmd.SendObject acSendNoObject,,acFormatRTF,Me![EmailAddress],,,,,-1<br><br>This assumes that you're working in a form and the name of the field with the e-mail address is [EmailAddress]. This will open a new e-mail message with the To field filled in.&nbsp;&nbsp;Take a look at SendObject in Help for a description of all your options.<br><br>
 
I use Access 2000 and if I set my Hyperlink like this mailto:whatever when I then click on the address it launches outlook with the appropriate address.&nbsp;&nbsp;Is that what you are trying to do?
 
Guys, i am wanting to do the same things (send an email when i hit the email address in one of the fields in my form) but i am having problems.

syntax error - then it highlights this ' outMessage.To = Your Field Name here
outMessage.Subject = Your message here

what am i doing wrong?

matt
 
More Choices! More Choices!
thread181-60871
Gord
ghubbell@total.net
 
Hi;
Is it possible to change the from field of the mail (in the code)?
Thanks;
Ariel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top