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

Email with Outlook

Status
Not open for further replies.

gustaf111

Programmer
Jan 16, 2011
87
SE
Hi, I use the code below to send e-mail with outlook. It works fine but the outlook window pop-up and I need to press the send button. How can I avoid that ? Security settings in outlook ? Some command from VBS ?

Gustaf

Dim myOlApp
Dim myItem
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(0)
myItem.Display
myItem.To = "<E-mail>"
myItem.Subject = "Message for you sir!"
myItem.Body = "Body here."
myItem.Save
AppActivate myItem
SendKeys("%s")
 
thread329-1552851 seems to have most of the answers if not the original source of your code, it still works for me under vb6 but fails on the AppActivate under vbs.

I remember reading something on an MS site recently that this problem (the security message) does not happen or can be avoided in Outlook 2007 and later.
 
I can confirm this doesn't happen with outlook 2007.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top