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

Forcing Email out of Outlook 1

Status
Not open for further replies.

white605

Technical User
Jan 20, 2003
394
US
Using VFP9 SP1, Outlook 2003 w/MapiLab Advanced security
In Click events I have been using code like
Code:
 o=createobject("outlook.application")
oNameSpace=o.GetNameSpace("MAPI")
oitem=o.createitem(0)
oteim.subject="subject"
oitem.to="email@whatever.com"
oitem.body="body of email"
oitem.send
o=.null.
release o,onamespace,oitem

I have recently added lines to try to force the send
Code:
 o=createobject("outlook.application")
oNameSpace=o.GetNameSpace("MAPI")
    ****added
oExplorer=o.Explorers.add(oNameSpace.folders[1],1)

oitem=o.createitem(0)
oteim.subject="subject"
oitem.to="email@whatever.com"
oitem.body="body of email"
oitem.send
            ***added
For Each thing IN oNameSpace.syncobjects
   oFoo=Thing
   oFoo.start
Endfor

o=.null.
release o,onamespace,oitem

With this code in several command button click events, my users are clicking one after another.
? When the command =o=.null. and release o runs, does this "kill" the session I created
? Should I put a timer or a loop to check the sent mail folder somehow before allowing the user to continue
Any tips on how to ensure the mail went out would be appreciated.

Thanks,
wjwjr
 
Try this instead

Code:
oOutlook = GETOBJECT(,"Outlook.Application")
oNameSpace= oOutlook.GetNamespace("MAPI")
oFolder = oNameSpace.GetDefaultfolder(4) 
oSend = oFolder.Items(1).Send

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
If I understand the question, the problem isn't sending to the Outbox, but doing a "Send pass." AFAIK, there's no way to do that via Outlook Automation.

Tamar
 
Sorry for the delay in reply,
Mike, will test the code you posted and report back

Tamar, the real problem is getting the mail "out" to the intended recepiant and "knowing" its out, I think I will try putting a unique tag in the subjectline and reading the last item in the sentitems folder in a loop until the unique item shows up there, halting other commands until the mail goes out or the user decides to click a button and activate the outlook session and check it manually.

wjwjr
 
Right. As I said, I don't know of a way to force a Send or Send/Receive in Outlook before it's scheduled or done manually. But once it's in the Outbox, your app has done its job.

If you really need to be sure the mail is sent, and you don't need it to show up in Sent Items, you could instead use something that bypasses Outlook, such as Blat.

Tamar
 
Even using blat you can only guarantee the mailserver has the mail. If you want to make sure the mail is delivered, you can request a delivery receipt. But not every mailserver supports that feature (Don't confuse this with Read Receipt, which must be supported by the mail client of the recipient).

If you want it tha sure, I'd start mail sending in a different process, that may warn the user if items stay too long in the outbox or tries to (re)start sending those items.

Bye, Olaf.
 
Thanks for all the replys -
Olaf, (request delivery recipt) - The Newspaper insustry is notoriously independent and beleive it or not will not click and type "i got it" .or. even click a return recipt if their client allows it. So, we email and Fax everything and then call them on the phone to be sure obituary notices are there before deadlines.

Sue at Outlookcode.com says "You can use the SyncObject.Start method to initiate a send/receive session, so that Outlook delivers messages in the Outbox to the appropriate downstream server and also downloads incoming messages, but it is not available in all Outlook versions."

This seems to work, still experimenting with this, and also working on reading the "SentItems" folder to check what went out. I will report back when I have working code

Again, thanks for the replys
wjwjr
 
Olaf, (request delivery recipt) - The Newspaper insustry is notoriously independent and beleive it or not will not click and type "i got it"

That's why I said: Don't confuse this with Read Receipt, which must be supported by the mail client of the recipient

A delivery receipt is NOT a read receipt.

A delivery receipt will be sent byck by the recipients mail server, if the mail was delivered to the recipient with no interaction from the recipient whatsoever.

Try this:
Code:
oOut = CREATEOBJECT("Outlook.Application")
oMail = oOut.CreateItem(0)
oMail.OriginatorDeliveryReportRequested = .T.
oMail.To = "youradress@yourdomain.com"
oMail.Subject = "delivery receipt test"
TEXT TO oMail.Body 
the sender may know this mail was delivered, 
if your mail server (not your mail client)
supports delivery receipt requests
ENDTEXT
oMail.Send()

Bye, Olaf.
 
Glad to hear there is a way to do this. Guess I learned there wasn't in one of those Outlook versions that didn't support it.

Tamar
 
Hello Tamar,

I tested this with Outlook 2003. Of course the sender mail client has to be capable to make the request. In my test I received two mails in return. One from the MAILER DEMON of the receiving mail server, one from the receiving mail client, which was the same Outlook 2003. So if you have bad luck with the receiving mail server or mail client the other may send back a mail.

Now what I would do additional to forcing mails out of the outbox is wait for the receipt mails and then inform the sender about the sucessful delivered mail. And I'd do this in a seperate process or thread, not wait for it. Let the application user do something else instead of waiting for the outbox to be empty. You may also warn, if a mail stays in the outbox longer than expected. But outlook does display a popup window anyway, if the mail server cannot be connected or there are different problems.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top