1 Attachment(s)
Outlook has to be running to send mail. HELP!!!
Im trying to send an email automatically with the push of a button. The only problem is that Outlook has to be running in order for the program to work. If outlook is not running, I get an error message (see mvberror.jpg below).
My code is;
Dim response
response = MsgBox("Do you want to send a message to Bev telling her you made a copy of " & lstfiles.FileName, vbYesNo, "STOP")
If response = vbYes Then 'User chose yes.
Dim objOutlook As New Outlook.Application
Dim ObjOutlookMsg As Outlook.MailItem
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = "email address"
.Subject = "test"
.Body = "Bev, " & vbNewLine
.Body = .Body & "I made a copy of drawing number: ** " & lstfiles.FileName
.Body = .Body & " **, from the Bravo folder. " & vbNewLine & vbNewLine
.Body = .Body & "Thanks"
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End If
When I press debug on the error, it returns me to
"Set objOutlookMsg = objOutlook.CreateItem(olMailItem)"
I dont want to have Outlook running in order to send the file. If anyone can help I would truely appreciate it.
Thanks in advance,
el guapo