Good morning, I'm developing an application in which I need to get a String Array and send it via Email directly from the application, would anyone have any idea how I can do it? Thanks
Good morning, I'm developing an application in which I need to get a String Array and send it via Email directly from the application, would anyone have any idea how I can do it? Thanks
Hello, I can pass you an example that I have done in C #, just pass your array of strings as a parameter.
public static void SendEmail(string email, string subject, string[] mensagem, String[] comCopia = null)
{
NetworkCredential("[email protected]", "password");
var assunto = subject;
var emailObj = email;
var mensagemObj = mensagem;
string from = new MailAddress("[email protected]", subject).ToString();
SmtpClient client = new SmtpClient("111.111.111.111")
{
UseDefaultCredentials = true,
Credentials = new NetworkCredential("[email protected]", "password"),
Port = 587
};
//string Server_Name = "http://" + Request.ServerVariables["server_name"] == "localhost" ? Request.ServerVariables["HTTP_HOST"] : Request.ServerVariables["server_name"] + "/project";
var html = string.Format("<p>Email: {0}</p>><p>Mensagem: {1}</p>",
email, mensagem);
var msg = new MailMessage(from, emailObj, assunto, mensagemObj) { IsBodyHtml = true };
if (comCopia!=null)
{
for (int i = 0; i < comCopia.Length; i++)
{
msg.CC.Add(comCopia[i]);
}
}
client.Send(msg);
}