How to attach and send external file through email

Best practices, code snippets for common functionality, examples, and guidelines.
gowthamp
Posts: 16
Joined: Fri Feb 05, 2016 7:19 pm

How to attach and send external file through email

Post by gowthamp » Tue Apr 05, 2016 8:04 pm

Hello,

I am updating file in "C:\Users\testuser\Documents\test.txt" local machine with time taken to complete module group in Ranorex.

In TEARDOWN I am converting report file to pdf and sending through email. I would like to attach and send updated "test.txt" file along with that pdf.
I am using the attached Csharp file to send reports in form of pdf through email.

Can someone guide me, in attaching external file along with PDF report?

Thanks,
Attachments
ReportToPDF.cs
(6.42 KiB) Downloaded 67 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to attach and send external file through email

Post by Support Team » Thu Apr 07, 2016 9:40 am

Hello gowthamp,

You simply can add the file as an attachment, as you already did with the PDF:

Code: Select all

attachment = new System.Net.Mail.Attachment("LOCAL FILE PATH");
                   mail.Attachments.Add(attachment);
Hope this information helps.

Sincerely,
Robert
.
Image

gowthamp
Posts: 16
Joined: Fri Feb 05, 2016 7:19 pm

Re: How to attach and send external file through email

Post by gowthamp » Fri Apr 08, 2016 3:24 pm

Thanks Robert,

Now I came to know how to attach external files.