You might be able to do this with Flow.
If not, you can have use System.Net.Mail:
public int SendEmail()
{
SmtpClient client = new SmtpClient(MailServer, 25);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = new System.Net.NetworkCredential(UserName, Password);
int retVal = 0;
try
{
client.Send(message);
}
catch (System.Net.Mail.SmtpException ex)
{
Trace.AddLog(EventLevel.Error, DateTime.Now, "Messaging", "SendEmail", "client.Send", ex.Message, "System.Net.Mail.SmtpException", string.Empty);
}
catch (System.Exception ex)
{
Trace.AddLog(EventLevel.Error, DateTime.Now, "Messaging", "SendEmail", "client.Send", ex.Message, string.Empty, string.Empty);
// System.Diagnostics.EventLog.WriteEntry("ExchangeSync", ex.Message, System.Diagnostics.EventLogEntryType.Error);
}
return retVal;
}
To Create the Email Message, you can use the following Syntax:
// From, To, Cc and Bcc are in the following Format: John Doe [john.doe@domain.com]
public void CreateEmailMessage(string From, string To, string Cc, string Bcc, string Subject, string Body)
{
message = new MailMessage();
int BracketPos = 0; string eMailAddress = "", DisplayName = "";
BracketPos = From.IndexOf("[");
if (BracketPos > 0)
{
eMailAddress = From.Substring(BracketPos + 1, From.Length - BracketPos - 2);
DisplayName = From.Substring(0, BracketPos);
message.From = new MailAddress(eMailAddress, DisplayName);
}
else
message.From = new MailAddress(From, From);
BracketPos = To.IndexOf("[");
if (BracketPos > 0)
{
eMailAddress = To.Substring(BracketPos + 1, To.Length - BracketPos - 2);
DisplayName = To.Substring(0, BracketPos);
message.To.Add(new MailAddress(eMailAddress, DisplayName));
}
else
message.To.Add(new MailAddress(To, To));
if (!string.IsNullOrEmpty(Cc))
{
BracketPos = Cc.IndexOf("[");
if (BracketPos > 0)
{
eMailAddress = Cc.Substring(BracketPos + 1, Cc.Length - BracketPos - 2);
DisplayName = Cc.Substring(0, BracketPos);
message.CC.Add(new MailAddress(eMailAddress, DisplayName));
}
else
message.CC.Add(new MailAddress(Cc, Cc));
}
if (!string.IsNullOrEmpty(Bcc))
{
BracketPos = Bcc.IndexOf("[");
if (BracketPos > 0)
{
eMailAddress = Bcc.Substring(BracketPos + 1, Bcc.Length - BracketPos - 2);
DisplayName = Bcc.Substring(0, BracketPos);
message.Bcc.Add(new MailAddress(eMailAddress, DisplayName));
}
else
message.Bcc.Add(new MailAddress(Bcc, Bcc));
}
message.Subject = Subject;
message.Body = Body;
message.IsBodyHtml = true;
}
Hope this helps.