troubleshooting Question

VB NET - Outlook Email (Outlook.Application)

Avatar of spen_lang
spen_lang asked on
Visual Basic.NETOutlook
3 Comments1 Solution10 ViewsLast Modified:
Hi,

I am using the following code to open a new Outlook email item and then attach attachments.

Is it possible to change the name of the attachment that is attached (e.g. actual file is "file.pdf" but I want the attachment to be named "test.pdf"?

Or do you have an alternative? However, I want the user to be able to check the email details before it is sent.

Thanks, Greg

Imports Microsoft.Office.Interop


Dim Outlook As Outlook.Application
Dim Mail As Outlook.MailItem

Outlook = New Outlook.Application
Mail = Outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)

Mail.To = "name@domain.co.uk"
Mail.Subject = "Test Email"
Mail.HTMLBody = "Hello World!"

Mail.Attachments.Add("C:\Path\To\File.pdf")

Mail.Display()

Open in new window

ASKER CERTIFIED SOLUTION
Éric Moreau
Senior .Net Consultant
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros