Click here to Skip to main content
15,902,275 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I would like to attach some files which are at uploading time, but not getting emails where I could save the files everything is good to run except 'AddAttachments' method.

What I have tried:

public ContentResult CompleteAssignedTask(int AssignedTaskId, string FromEmail, string[] fileNames)
{
var client = new SendGridClient("mycode");
var from = new EmailAddress("director@gmail.com", "The awsome");
var to = new EmailAddress(customer.Email, customer.CustName);
var htmlContent = body;
var msg = MailHelper.CreateSingleEmail(from, to, taskRecord.Subject, "", htmlContent);
msg.AddAttachments(fileNames);
var response = client.SendEmailAsync(msg);
} 
Posted
Updated 29-May-19 2:33am
Comments
OriginalGriff 29-May-19 7:33am    
Please don't post the same thing under two different IDs - that doesn't improve your chances of getting a response, it lowers it.

I'll delete the newer version.

1 solution

You call the API the wrong way.

If you have a look at the API you will see that the method 'AddAttachments'
does not accept IEnumerable<string> as input parameter.
public void AddAttachments(IEnumerable<Attachment> attachments)
{
	...
}

It accepts IEnumerable<Attachment>.

You should download the source code from GitHub

https://github.com/sendgrid/sendgrid-csharp

in order to understand the API.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900