Outlook2007 Email problem with automation

D

Dennis Rose

I am using automation in a VB5 program to send Emails using Outlook2007. If
I use the ".Send" mailitem the email is sent out Immediately.

If I use the ".Display" mailitem in my program, after I look over the Email
and then click the "Send" button on the Outlook display screen, the email is
placed in my outbox but does not get sent out. I have to exit my program and
then click "Outlook". When Outlook displays, I can see the Email in the
Outbox which will then automatically go out (without me having to click send
and receive).

I want the Email to immediately go out (when using the ".Display" mailitem
in my program) after clicking the "Send" button on the Outlook display
screen.

What do I need to do??
 
D

Dmitry Streblechenko

Do you immediately set the variable poiting to the message to Nothing?
What is the relevant snippet of your code?
Are you sending through SMTP or Exchange?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
D

Dennis Rose

Thanks for the reply!

I am sending thru SMTP.

This is my code:

Private Sub SendEmail()
Dim OutApp as Outlook.Application
Dim OutMail as Outlook.MailItem

If OutlookPresent = True Then
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(olMailItem)

With OutMail
.To = txtEMailAdr.Text
.CC = ""
.BCC = ""
.Subject = "Customer Follow-Up"
.SendUsingAccount = OutApp.Session.Accounts.Item(1)
.Display
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

MsgBox "Email Sent"
End If
End Sub
'********************************
 
D

Dennis Rose

I forgot to include the ".Body = "Test email"" instruction but it is there.
 

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

Top