outlook automation

T

Tom D.

I am using outlook automation from my access database. Previously when I sent
an email (see code), Outlook did not need to be running, it would work either
way. Now, only if Outlook is running. Errors out with it closed.
Am I missing something obvious here???
TIA
--


Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient


Dim strRecip As String


Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)


'Create email body & subj...
With objOutlookMsg
.Subject = "<<<CCS Change Management update>>>"
.Body = strMsgBody
.Recipients.Add strRecip

'Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
 
Top