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()
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()