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 problem with Outlook XP

Status
Not open for further replies.

RichardH

Programmer
Apr 21, 2001
46
US
I have been using code similar to this to create a bulk email for everyone in the table mydatabase:

scan
oApp = createObject("Outlook.Application")
oMail = oApp.CreateItem(0)
oMail.to=alltrim(mydatabase.emailaddress)
oMail.subject = "Subject here"
oMail.body = "Email body test here"
oMail.send()
release oApp
release oMail
endscan

It works great with Outlook 2000 but with Outlook XP it has problems. I get a couple of messages and the user is forced to press the "Yes" button for each message to be sent. Here are the messages:

"A program is trying to send mail using Item.Send

A program is trying to automatically send email using a Microsoft Outlook Visual Basic command, Item.send. If you want this program to send this email, click Yes. To stop the program click No. If you are unsure which program is sending the email or why, you may want to click No to avoid any possible spread of viruses.

Note: when this message is displayed the Yes button is not available for 5 seconds"

Then a box appears where you can press Yes or No. The big problem is that the user has to wait 5 seconds and press Yes for each email.

I think I understand what Microsoft is trying to do here but hope there is a way around it without asking users to go back to Outlook 2000.

Thanks for any help.
 
Mike Krausnick,

Thanks again for keeping after this. The West-Wind WWIPStuff was a no-go becuase it required to much setup on my users computers, which I can't fully control and the CDO stuff seems to be going nowhere.

This leaves me with Outlook Redemption with which I seem to be very very close. Your command for adding extra recipients worked great but the others,

oMsg.Body = "Message Text"
oMsg.Sender or oMsg.SenderName

don't work for me. I may be able to live without changing the senders name but messages without any text in the body aren't much good.

I know there is line of code to add bodytext but I just can't seem to guess the syntax. I am a bit worried that the author of Outlook Redemtion didn't include it in his example.

Thanks once again....Rick
 
Rick

If I take Mike's code :
Code:
local OutlookItem, SafeItem, oItem, Namespace  
Aplication = CreateObject("Outlook.Application")
Namespace = Aplication.GetNamespace("MAPI")
Namespace.Logon
SafeItem = CreateObject("Redemption.SafeMailItem") 
oItem = Aplication.CreateItem(0) 
SafeItem.Item = oItem  
SET STEP ON  && Brings up the debugger, and allows me to look in the Local Window at the SafeItem different parameters
You will notice:

AuthKey
bbc
body
cc
receivedbyname
receivedonbehalfofname
replyrecipientname
rtfbody
sendername
sentofbehalfofname

Hope that helps
 
Well I think I have finally figured it all out. Thanks Mike for all your help. As it turns out your code for Outlook Redemption was correct. To populate the body of the message your code suggestion:

SafeItem.body="Put text of message here"

does work, it just didn't appear to be working because when you look at the email in the Outlook "Drafts" folder where it places it or even in the "Sent Items" folder after it is sent, the is no text in the message. BUT the recipient gets the message with the text OK. I don't know why that is, but I can live with it.

For anyone else that may be curious I have settled on this as my final code which seems to work well. For the computers with Outlook 98 or Outlook 2000 I use this:

oApp = createObject("Outlook.Application")
oMail = oApp.CreateItem(0)
oMail.to = "someone@somewhere.com"
oMail.subject = "Email from VFP"
oMail.body = "This works for Outlook 98/2000"
oMail.send()
release oApp
release oMail

For computers with Outlook 2002 I installed Outlook Redemption (see above for url) and use this code.

local OutlookItem, SafeItem, oItem, Namespace
Aplication = CreateObject("Outlook.Application")
Namespace = Aplication.GetNamespace("MAPI")
Namespace.Logon
SafeItem = CreateObject("Redemption.SafeMailItem")
oItem = Aplication.CreateItem(0)
SafeItem.Item = oItem
SafeItem.to = "someone@somewhere.com"
SafeItem.Subject = "Email from VFP"
SafeItem.body="This works for Outlook 2002"
SafeItem.Recipients.ResolveAll
SafeItem.Send
*** need to add code here to return to program path

Thanks again to everyone for all the help!

Rick
 
i have installed redemption and used the VB code as in RichardH last post - still no glee here. Outlook 2002, XP Pro, VB6. Please, what am I missing?
"Namespace=" line gives me "Object required" error.
Any help is appreciated.

Michael
 
It's possible the MSMAPI.ocx in not installed on your computer. Do a search on your computer for anything MAPI.
 
To anyone involved in this thread...

SafeItem.Recipients.ResolveAll

Can anyone tell me why the above line is necessary before sending or saving an email?

TIA
Alan Harris-Reid
 

SafeItem.Recipients.ResolveAll

Can anyone tell me why the above line is necessary before sending or saving an email?


You may wan to ask the originator of the fix:
dmitry@dimastr.com
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top