[SOLVED] Send attachments with MailKIt which comes from a website


I´m using asp.net with c#

I send emails with MailKit including pdf attachments.
These pdf files are at the moment on my local computer.
This works so far without any problems.
For the local files I specify the path like this.


Now I have the problem that the pdf attachments have to be loaded directly from a website.

i.e.: https://website.com/files/06/atachment.pdf

Is this possible with Mailkit?
How do I specify the path?


Include this namespace

using System.Net;

Download your files to a path using WebClient class

using (WebClient wc = new WebClient())
    wc.DownloadFile (
        // Param1 = Link of file
        new System.Uri("https://website.com/files/06/atachment.pdf"),
        // Param2 = Path to save

and then attach as usual


Answered By – Nitin S

Answer Checked By – Jay B. (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *