Hi
I am trying to send emails using word vba and outlook. If outlook is running then all is fine. If outlook is not running then the email sits in the outbox until you start outlook, then it is sent.
Office 2010, Win 7.
Relevant code is
'start outlook in the background if not already running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'create and send the email
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = strEmailAddress
.Subject = "Quotation Please"
.Attachments.Add Source:=strFileName & ".pdf"
.Send
End With
'clean up
If bStarted Then
oOutlookApp.Quit
End If
Set oItem = Nothing
Set oOutlookApp = Nothing
The rest of the code builds the string variables and exports the document as a PDF, which I'm happy to post.
Bit stuck, help please
Many thanks
I am trying to send emails using word vba and outlook. If outlook is running then all is fine. If outlook is not running then the email sits in the outbox until you start outlook, then it is sent.
Office 2010, Win 7.
Relevant code is
'start outlook in the background if not already running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'create and send the email
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = strEmailAddress
.Subject = "Quotation Please"
.Attachments.Add Source:=strFileName & ".pdf"
.Send
End With
'clean up
If bStarted Then
oOutlookApp.Quit
End If
Set oItem = Nothing
Set oOutlookApp = Nothing
The rest of the code builds the string variables and exports the document as a PDF, which I'm happy to post.
Bit stuck, help please
Many thanks