This is a modified version of previous message, but I haven't found a suitable solution to my problem yet.
Using Visual Foxpro 7 and Outlook XP (with XP pro), I am creating email messages and sending them to the Outbox, but they are not actually being sent unless I go to the folder and send them manually. Is there any way to ensure that the emails are sent automatically? The email server is definitely running in the background. If I close and reopen Outlook manually, the emails in the outbox are sent immediately (I guess because the 'Send/receive upon connection' checkbox is ticked).
The code is as follows...
* ---------------------------------------------------
LOCAL oOutLook, oMailItem, oSafeMailItem, oNameSpace
oOutlook = CREATEOBJECT("Outlook.Application")
oMailItem = oOutlook.CreateItem(0)
* The following lines are only required if addressing outlook folders.
* oNameSpace = Outlook.GetNameSpace('MAPI')
* oNameSpace.logon
* Redemption is used to by pass MSFT security messages
oSafeMailItem = CREATEOBJECT("Redemption.SafeMailItem")
oSafeMailItem.Item = oMailItem
WITH oSafeMailItem
.Recipients.Add("
someone@somewhere.com")
.Recipients.ResolveAll()
.Subject = "This is the subject"
* NOTE: if sending HTML string, string must be stored to both
* .body AND .HTMLbody properties. (As recommended by Redemption, author 31/10/02)
.body = lcHTMLString
.HTMLbody = lcHTMLString
.Send()
ENDWITH
* ---------------------------------------------
As a workaround, I thought of programmatically closing Outlook, then opening it again to make it appear as if it had been opened manually. That didn't work either. The additional code was as follows...
STORE .NULL. TO oOutLook, oMailItem, oSafeItem
RELEASE oOutLook,oSafeItem, oMailItem
* Reopen Outlook
oOutLook = CREATEOBJECT('Outlook.application')
Any help would be appreciated. This problem is really bugging me (pardon the pun).
Alan Harris-Reid