c# - How to send emails with List<string>() using Send Grid mvc azure -


i reading send grid documentation, , below states in order add emails of recipients, required:

    // add multiple addresses to field. list<string> recipients = new list<string> {     @"jeff smith <jeff@example.com>",     @"anna lidman <anna@example.com>",     @"peter saddow <peter@example.com>" };  mymessage.addto(recipients); 

meanwhile in code have list string stored emails.

 emailing.find_email_send = new list<string>();  emailing.find_email_send.add("nick@hotmail.com");  emailing.find_email_send.add("john@hotmail.com");  emailing.find_email_send.add("jack@hotmail.com"); 

how can add recipients ? tried using forloop:

recipients.add(emailing.find_email_send[i]); 

but doesn't seem work.

if mymessage.addto method takes list parameter , have addresses in list, don't need except:

mymessage.addto(emailing.find_email_send); 

if want add addresses list recipients list be:

var recipients = new list<string>(); foreach (var address in emailing.find_email_send) {     recipients.add(address); } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -