- Posts: 41
- Karma: 2
- Thank you received: 8
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
try
{
Console.WriteLine("Email Sender - Standard");
/*Configuration of the SMTP Client*/
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
client.Credentials = new System.Net.NetworkCredential("username", "password");
client.EnableSsl = true;
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
/*Configuration of the EMAIL object*/
System.Net.Mail.MailAddress fromMail = new System.Net.Mail.MailAddress("email", "Easy Iot Server", System.Text.Encoding.UTF8);
System.Net.Mail.MailAddress toMail = new System.Net.Mail.MailAddress("email");
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(fromMail, toMail);
message.Subject = "test message 2";
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.Body = "This is a test e-mail message sent by an application. ";
message.BodyEncoding = System.Text.Encoding.UTF8;
/* Opening of the web request stream to get the image from the camera */
string strFile = "http://192.168.0.14/cam.jpg";
string strLocalFile = "/tmp/cam.jpg";
System.Net.WebRequest objWebRequest = System.Net.WebRequest.Create(strFile);
System.Net.WebResponse objWebResponse = objWebRequest.GetResponse();
System.Net.Mail.Attachment objAttachment = new System.Net.Mail.Attachment(objWebResponse.GetResponseStream(), strLocalFile);
/* Attach the image to the email*/
message.Attachments.Add(objAttachment);
/* Sending the message */
client.Send(message);
Console.WriteLine("Message Sent.");
}
catch (Exception e)
{
Console.WriteLine("An Exception occurred: '{0}'", e);
}
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.