Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending different mail content to same recipient does not work well #520

Closed
SRossi77 opened this issue Sep 12, 2017 · 2 comments
Closed
Labels
status: help wanted requesting help from the community type: question question directed at the library

Comments

@SRossi77
Copy link

Issue Summary

I am using a send grid method to send multiple files to same recipient by using substitutions tags.
I need this to work because sometimes i need to send multiple emails with different content to same recipient.

I am using Rest Request:
IRestResponse response = new RestClient(SendGridClientUrl).Execute(request);

Request Object:( Custom Request for send grid )
EmailAddress fromMail = new EmailAddress("no-reply@test.com", "");
List emails = new List()
{
new EmailAddress("skhatiwada@test.com","Sujit Tester"),
new EmailAddress("skhatiwada@test.com","Sujit Tester")
};
var subjects = new List { "Test for -name-.", "Test for -name-."};
var plainTextContent = "Hello -name-. We are ready to use -Sample-.";
var htmlContent = "Hello -name-. We are ready to use -Sample-.";
var substitutions = new List<Dictionary<string, string>>
{
new Dictionary<string, string>() {{"-name-", "Sujit Tester"},{"-Sample-","If you are Tester then,
this test is working fine." } },
new Dictionary<string, string>() {{"-name-", "Sujit Developer"}, { "-Sample-", "If you are
Developer then, this test is working fine." } }
};
SendGridMessage sendGridMessage = MailHelper.CreateMultipleEmailsToMultipleRecipients(
fromMail,
emails,
subjects,
plainTextContent,
htmlContent,
substitutions);
SendBulkEmail(sendGridMessage);

Steps to Reproduce

The problem here is that, i am not able to get both the mails under a single recipient in my outlook mail. At times i get the first substituted mail and other times i get the second substituted mail. I tried this and some cases it sent both mails with different mail contents as well, but this is not trustworthy.

Technical details:

  • sendgrid-csharp : [v3/Send ]
  • Platform (ASP.NET)
  • .NET Version: 4.5
@Niladri24dutta
Copy link
Contributor

Niladri24dutta commented Sep 12, 2017

What is the usage of SendBulkEmail(sendGridMessage); here ? it is a custom method?as per the V3 documentation we need to use var client = new SendGridClient(apiKey); and to send the email like below var response = await client.SendEmailAsync(msg); .
Take a look at this link
Use case for sending email

@thinkingserious thinkingserious added status: help wanted requesting help from the community type: question question directed at the library labels Sep 12, 2017
@thinkingserious
Copy link
Contributor

Thanks for jumping in and trying to help @Niladri24dutta!

@SRossi77,

Have you reviewed our templating use case? It's very similar to what you are trying to do.

Also, duplicate emails are not allowed. That may a source of error also.

With Best Regards,

Elmer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: question question directed at the library
Projects
None yet
Development

No branches or pull requests

3 participants