Click here to Skip to main content
15,885,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I have a SSIS script task in which I will use this component to send email to multiple users. However, when the SSIS package is being executed, it returns me the error message as above title. Previously it runs fine, this is the first time that I am getting this error. I have checked my input data, all email addresses are in corrrect format, no double dot or full stop, correct domain, etc.
Below are my codes:
using (MailMessage message = new MailMessage())
            {
                MailAddress from = new MailAddress("Sender@domain.com", "Customer Information");
                message.From = from;

                to = ChangeSeprators(to); //to split input string. e.g. abc@domain.com;def@domain.com
                if (!string.IsNullOrEmpty(to))
                {
                    message.To.Add(to);
                }

                cc = ChangeSeprators(cc);//to split input string. e.g. abc@domain.com;def@domain.com
                if(!string.IsNullOrEmpty(cc))
                message.CC.Add(cc);
                
                message.Subject = emailSubject;
                message.Body = emailBody;
                message.Attachments.Add(new Attachment(attachment));
                message.BodyEncoding = Encoding.UTF8;
                message.IsBodyHtml = true;

                SmtpClient smtpClient = new SmtpClient(server);
                try
                {
                    smtpClient.Send(message);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }


What I have tried:

1. Checked email addresses/input which are all correct.
Posted
Updated 12-Feb-17 21:39pm

1 solution

It's going to be data dependant - that code looks a lot like mine which works fine - so you need to use the debugger and look at exactly what is happening, and in particular what your ChangeSeprators method is getting as an input and returning. Since to and cc require valid emails (not just the from address) they need to be carefully checked. I'm a little concerned that that code isn't exactly what you are running - it isn't indented perfectly, which normally means it's "edited down" from the full method and that may be "hiding" things which are causing problems.

Sorry, but we can't do that for you!
 
Share this answer
 

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