keep a person in CC while sending an email using BluePrism

quicosans

New Member
Hi, This works well for me but when I don't want to use CC or BCC and leave the data items blank I get the following error:

Internal : Could not execute code stage because exception thrown by code stage: The parameter 'addresses' cannot be an empty string.
Parameter name: addresses

Is there a workaround please so I can use this VBO for processes that use CC and don't use CC.

Hi ,

I've got the same issue. The only work arround I found is by creating different pages one sending email only TO and CC and another page only sending email TO and BCC
 

Sachin_Kharmale

Active Member
Hi @Gazmo,
Use bellow Code in your send Message action it will work if you keep your cc blank or you keep in cc someone for both cases it will work.

C#:
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };


SmtpClient client = new SmtpClient();
try
{
    client.Host = Server;
    client.Port = (int)Port;
    if (Username != "")
        client.Credentials = new NetworkCredential(Username,Password);
    client.EnableSsl = UseSSL;
    
    using(MailMessage mail = new MailMessage())
    {
        mail.From = new MailAddress(From);
        mail.To.Add(To);
        mail.Subject = Subject;
        mail.IsBodyHtml = BodyIsHTML;
        mail.Body = Body;
        if (CC != "")
            mail.CC.Add(CC);
        foreach(DataRow dr in Attachments.Rows)
        {
            string file = dr["Path"].ToString();
            Attachment data = new Attachment(file, MediaTypeNames.Application.Octet);
            ContentDisposition dis = data.ContentDisposition;
            dis.CreationDate = File.GetCreationTime(file);
            dis.ModificationDate = File.GetLastWriteTime(file);
            dis.ReadDate = File.GetLastAccessTime(file);
            mail.Attachments.Add(data);
        }

        client.Send(mail);
    }
}
catch(Exception ex)
{
    string msg = ex.Message;
    if(ex.InnerException != null) {
        msg += " - " + ex.InnerException.Message;
    }
    throw new Exception(msg);
}
finally
{
    IDisposable disposableClient = client as IDisposable;
    if (disposableClient!=null)
        disposableClient.Dispose();
}

Note: Add CC input parameter in your action input.

I hope it will help you.!!
 
Top