CDO generated message stuck in Outbox

U

Upul Samaranayake

I am trying to use the CDO code below (based on MSDN) to send a mail
message. The code is run from within 'ThisOutlookSession'.

The problem is that the message sits in the Outbox.. does not get picked up
and delivered by Exchange. Subsequently, if I create and send a message
interactively using Outlook, then both messages get delivered immediately.

Looks like I need to trigger something at the end of this code. Not quite
sure what. Any ideas?

TIA

-----

Sub test()

Dim objSession As New MAPI.Session
objSession.Logon , , False, False
Dim objMessage As MAPI.Message

Set objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = "Sample Message"
objMessage.Text = "This is some sample message text."

' create the recipient
Set objOneRecip = objMessage.Recipients.Add
objOneRecip.Name = "Fulano DeTal"
'objOneRecip.Type = CdoTo
objOneRecip.Resolve

' send the message and log off
objMessage.Update
objMessage.Send False, False
Set objMessage = Nothing
objSession.DeliverNow
objSession.Logoff

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top