Send Email "Operation Failed"

K

Kenny G

Hello,

Using Office 2007

Below is my code in a mod that a call from a command button on a form.
Everything opens up just fine and the attachment is where it ought to be,
but, I get the message "Operation Failed" when I click the send button in
outlook. Any ideas on where I went wrong on my code?

Thanks in advance.

Sub InmateReport(Optional AttachmentPath)

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookAttach As Outlook.Attachment
Dim objOutlookRecip As Outlook.Recipient
Dim sBody As String

'Create the Outlook session
Set objOutlook = CreateObject("Outlook.Application")

'Create the e-mail message and add the attachment to the e-mail message.

Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

sBody = "Attached is the Daily Inmate In House Report. In an effort to
increase/continue compliance with Joint Commission Standards please<br>"
sBody = sBody & "review as required. You may contact Pete Valdez
or Michelle Ingram should you have any questions.<br><br>"
sBody = sBody & "Thank You,<br><br><br>"
sBody = sBody & "Pappy Valdez<br>"


With objOutlookMsg

.To = "(e-mail address removed)" ';[email protected];Protective
Services Communication Mail Group"
.Subject = "Daily Inmate In House Report!"
.Importance = olImportanceHigh
.HTMLBody = sBody
.Display
.Attachments.Add ("\\Sharedir\jcaho documentation\InmateTracking\Daily
Inmate In House Report.rtf")

End With

Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookAttach = Nothing
Set objOutlookRecip = Nothing
 
K

Kenny G

I have tested it with the .send and it works.
I want to not and the .send in case the user has to add another name.
 

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