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

FluentEmail v3.0.0/ Multiple Cc and Bcc Recipient Issue #287

Open
MTKor opened this issue Oct 7, 2021 · 7 comments
Open

FluentEmail v3.0.0/ Multiple Cc and Bcc Recipient Issue #287

MTKor opened this issue Oct 7, 2021 · 7 comments

Comments

@MTKor
Copy link

MTKor commented Oct 7, 2021

I am working on an urgent project involving FluentMail to process outgoing email messages.

The problem is that I have not been able to figure out a way to send Cc and/or Bcc messages to multiple recipients, only one.

I have also tested it with hard-coded recipients, like
"tom.tom@acme.com; mickey.moustache@acme.com; don.don@somekiosk.com" OR
"tom.tom@acme.com, mickey.moustache@acme.com, don.don@somekiosk.com".

What happens is that the Cc or Bcc message ends up being sent only to the last recipient in the list.

I would very much appreciate advise on how to send a message to multiple Cc and Bcc reciepients and, if this feature is not currently supported, I hope that this feature would be implemented soon.

@McPhale
Copy link

McPhale commented Oct 7, 2021

You can generate a list of Address (Address is in FluentEmail.Core.Models) and then pass it into .BCC().

Something like this.

_BCCAddresses = config.GetSection("BCCAddresses").Get<List<string>>().Select(ea => new Address { EmailAddress = ea }).ToList();

var email = _emailFactory.Create()
  .To(toAddress) 
  .BCC(_BCCAddresses)
  .Subject("Subect")
  .UsingTemplateFromFile($@"path\to\template", model, true);

@MTKor
Copy link
Author

MTKor commented Oct 9, 2021

Thank you for your help. C# is still quite new language to me so excuse me for that.
I made a test and added some email addresses to a list hard-coded and it seemed to work i.e. the Cc and Bcc messages were sent to each listed recipient.

I understand that your given example reads a list and returns a list, right? In my case, I get a string containing the email addresses separated by semicolon ";". Could you suggest a handy way to add all those email addresses to a list that would be passed to .CC or BCC?

Thanks in advance.

@McPhale
Copy link

McPhale commented Oct 11, 2021

No worries :) you can use string.split() for that.
Here's an example

var emailString = "test1@test.com;test2@test.com;test3@test.com";
var listOfAddress = emailString.Split(";").Select(ea => new Address { EmailAddress = ea }).ToList();

@MTKor
Copy link
Author

MTKor commented Oct 14, 2021

Thanks a lot for your assistance. I got it working now. It is strange, though, that you can just pass a string like
"tom.tom@acme.com; mickey.moustache@acme.com; don.don@somekiosk.com" to .TO() and it works, but the same does not apply to .CC() or .BCC(). I just wonder why is that?

@McPhale
Copy link

McPhale commented Oct 14, 2021

It's just not implemented yet; see #180

Looks like there's already a pull request active for it.

@MTKor
Copy link
Author

MTKor commented Oct 15, 2021

Ok, hope it will be merged soon. Is it possible to look at the implementation code?

@McPhale
Copy link

McPhale commented Oct 15, 2021

2569026 (#180)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants