Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening outlook and attaching files

Status
Not open for further replies.

nzcam

Programmer
Mar 5, 2003
36
0
0
NZ
Hi, I am having trouble with the attachment of a file to a outlook email.

I am trying to open outlook with new email that holds an attachment.

Here is the code, Everything works OK except the attachment.add code get and exception

Please help

Thanks



Try

'Create Outlook application.
Dim OutlookApplication As Outlook.Application = New Outlook.Application

'Create MailItem.
Dim OutlookMailItem As Outlook.MailItem = CType(OutlookApplication.CreateItem(OlItemType.olMailItem), Outlook.MailItem)

' Net 2 lines of code caus exception!!
'Dim maAttachment As MailAttachment = New MailAttachment("C:\\temp\Capture_Screen.jpg")

'Add attachment to the Attachments collection.OutlookMailItem.Attachments.Add(img)

'Set To and Subject of the email. OutlookMailItem.To = "email address"

OutlookMailItem.Subject = "About email sending through Microsoft Outlook"

'Display MailItem.
OutlookMailItem.Display()

 
OutlookMailItem.Attachments.Add(img)
What is "img"?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks, That simple question you asked made me look back at img (img is the output from a screen capture class).

I was saving the screen image as a jpg file that I wanted to email but I wasand trying to send the actual image in the email not the saved jpg image.

So Simple.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top