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!

Getting the email to: Name to automatically populate

Status
Not open for further replies.

Goot

Programmer
Aug 4, 2005
86
US
I am adding a routine to send an email automatically to alert someone that something has been entered into the database. How can I automatically get the names of the email to: into the body of the email so that when they send it...nobody has to enter the name..
 
I use this code aand it seems to work OK

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

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

With objEmail
.To = "somebody@somewhere.com"
.Subject = "Useful Description"
.HTMLBody = ""
.Display

End With

Regards
 
Ok thanks...
One other thing...

I would like my email to be triggered automatically. The outlook form comes up with the names and the subject ok...But I want this to go out automatically.
I have used the SendObject in the past, but I am using the Outlook references. Again, how do you invoke the email to be sent automatically.
 
Replace .Display by .Send
Doing that you may discover the Outlook Object Model Guard ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OK .Send does what I want...one more hurdle to cover...
I am getting the following message in a small window in
Outlook...


A program is trying to access your Address Book
A program is trying to access your Address Book or Contacts. Viruses can spread by sending copies of e-mail messages to people listed in your Address Book. You must allow or deny access to your Address Book before this program can continue.

Allow access

Do one or both of the following:

To allow the program access for this instance only (such as for one contact), click Yes.
To allow unsecured access for a specified time period of up to 10 minutes, select the Allow Access for check box, and then click a time period in the list.
Deny access

Click No.

How can I bypass this...or do I need to sendkeys or something like that.

Again thanks
 
I've forewarned you ...
Do a google search for outlook object model guard

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top