Attachment Type VS2005

G

Guest

I want to send an email containing a MemoryStream, when I try to add the
attachment, I get a "Could not complete the operation. One or more parameter
values are not valid.".
Here is the code I am using in VS2005 with VB.NET.

Try

Dim oOutL As New Microsoft.Office.Interop.Outlook.Application
Dim oMail As Microsoft.Office.Interop.Outlook.MailItem

oMail =
oOutL.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
oMail.UnRead = True
oMail.To = "(e-mail address removed)"
oMail.ReadReceiptRequested = False
oMail.Subject = "Test of Automated Daily Safety Report"
oMail.HTMLBody = True
oMail.Body = "This is a test"
oMail.Attachments.Add(New Attachment(stmReportStream,
"DailySafetyReport.PDF"))
oMail.Send()

Catch ex As Exception
Console.Write("Send_Daily_Report subroutine FAILED! Project
prjSafetyDailyAuto")
End Try

What am I doing wrong?

Thanks,
W
 
D

Dmitry Streblechenko

Attachments.Add can take either a string with the name of the file to be
attached or a pointer to another Outlook item (MailItem, ContactItem, etc)
to be attached as an embedded message.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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