Page 1 of 1

send multiple emails

Posted: Thu Feb 12, 2015 6:43 am
by Danny

Hi,

We try to send multiple emails of a selected database to all recipients.

Now we use:

sBBC = abc = ew_Execute("SELECT emailfield FROM <Table> WHERE emailfield <> '' ")

All emailaddresses has an ; at the end.

We get an error:

The parameter 'addresses' cannot be an empty string.

Line 5481: string[] arBcc = sBccEmail.Split(new char[] {';'});
Line 5482: foreach (string strBcc in arBcc)
Line 5483: mail.Bcc.Add(strBcc);


Re: send multiple emails

Posted: Thu Feb 12, 2015 5:34 pm
by vincenthung

Please note that ew_Execute() returns an integer. You may consider to use "ew_ExecuteRows" which will return a list Of OrderedDictionary. Then you can loop through the list and call the AddBcc() method of the Email object.


Re: send multiple emails

Posted: Fri Feb 13, 2015 9:46 am
by Webmaster

Make sure that you remove the last semi-colon (";") at the end of the email addresses (i.e. "mail1@domain;mail2@domain;...;mailn@domain")

Post your complete code for discussion.


Re: send multiple emails

Posted: Sat Feb 21, 2015 7:33 pm
by Danny

Hi,

This is the code:

Dim sSender As String, sRecipient As String, sCc As String, sBcc As String, sSubject As String, sContent As String, sFormat As String, sCharset As String
sSender = <emailaddress-sender>
sRecipient = ""
sCc = ""
sBcc = ew_ExecuteScalar("SELECT <emailaddress> FROM <customers>")
sSubject = "<subject>"
sContent = "<content>"
sFormat = "html"
sCharset = "utf-8"
ew_SendEmail(sSender, sRecipient, sCc, sBcc, sSubject, sContent, sFormat, sCharset)

The problem is the BCC executeScalar.

Regards,


Re: send multiple emails

Posted: Mon Feb 23, 2015 10:02 am
by Webmaster

As explained:
Make sure that you remove the last semi-colon (";") at the end of the email addresses (i.e. "mail1@domain;mail2@domain;...;mailn@domain")

For example:
If Right(sBcc,1) = ";" Or Right(sBcc,1) = "," Then sBcc = Mid(sBcc,1,Len(sBcc)-1) ' Remove last ";" / ","