View Full Version : excel/outlook redux

11-04-2006, 10:59 PM
I am running Office 2003. Using the following code segment

Dim objOLapp As Object 'New Outlook.Application
Dim objmailitem As Object 'Outlook.MailItem
Dim myrecip As Object 'Outlook.Recipient
Set objOLapp = CreateObject("Outlook.Application")
'Set objOLapp = New Outlook.Application
Set objmailitem = objOLapp.CreateItem(olMailItem)
Set myrecip = objmailitem.Recipients.Add("joe blow")
With objmailitem

.To = Recipients
.Subject = " Morning Report"
.Attachments.Add "S:\PV\report.xls"
End With
Set objOLapp = Nothing
Set objmailitem = Nothing
Set myrecip = Nothing

I presumed that the set as new outlook would open the application. It doesn't seem to. The .display line does show the email.
The big issue facing me is that the mail does not send until i subsequently open Outlook and it performs a Send/Recieve. Outlook is set to send/recieve online/offline. Aware that the object model has a lot of new security restraints, but any suggestions for what should be a simple issue would be appreciated.

I resubmitted this request since the forum previously had a habit of kicking me.

Simon Lloyd
11-05-2006, 11:09 AM
This is what i have and it works fine
Sub Sendmail()
Dim olApp As Object
Set olApp = CreateObject("outlook.application")
With olApp.CreateItem(0)
.To = "xxx@xxx.com"
.Subject =
.Body =
End With
Set olApp = Nothing
End Sub
you could always try Ron De Bruins site he has lots of stuff on send mail or an add in here http://www.rondebruin.nl/mail/add-in.htm regards,

11-05-2006, 11:18 AM
In your Outlook program:
Tools/Options....select the mail setup tab and make sure "send immediatly when connected" is checked.

11-05-2006, 06:11 PM
Apparently, some sites advise to uncheck the Send immediately when connected tab, because of a bug in some Outlooks. Yeah, the code all looks good, but the mail won't send until i physically open Outlook. Seems odd that Outlook doesopen to resolve the addresses, but not to send the mail.