-3

I am using SendGrid to send email using C# from visual Studio. I have been successful sending email so far.

Now I want to attach a zip folder to the email that is I am creating using SendGrid. How I can attach a zip folder?

I have seen example for pdf, jpeg but I am specific about zip file or folder, in other words what would be the varible of the attachement properties following below:

attachment = new Attachment()
        {
            Content = ?,
            Type = ?
            Filename = "MyFilesFolder2.zip",
            Disposition = "inline",
            ContentId = ?
        };

Thanks

Asal
  • 49
  • 1
  • 5
  • Actually, I am not talking about just any document I am talking about zip file. What would be the value of the attachment variable when attaching the zip to an email. – Asal Dec 17 '17 at 23:44
  • You don't need to change these values from their default values. `myMessage.Attachments.Add(new Attachment("C:\Path\To\MyFilesFolder2.zip"));` will work perfectly fine. – Heinzi Dec 18 '17 at 15:04

1 Answers1

0

You seem to be confused by MS Windows displaying ZIP files as folders. ZIP files are not folders, they are just files, like any other file.

Thus, you'd add them to an e-mail just like you would add any other file. See the following SO question for details:

If you don't have a ZIP file yet and want to create one (based on an existing folder), that's an entirely different question. Fortunately, it has been answered here as well:

Heinzi
  • 151,145
  • 51
  • 326
  • 481