[sourcecode language="csharp"]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
namespace email
{
class Program
{
static void Main(string[] args)
{
try
{
//The From address (Email ID)
string str_from_address = "sender_email_address";
//The Display Name
string str_name = "Test Mail";
//The To address (Email ID)
string str_to_address = "receiver_email_address";
//Create MailMessage Object
MailMessage email_msg = new MailMessage();
//Specifying From,Sender & Reply to address
email_msg.From = new MailAddress(str_from_address, str_name);
email_msg.Sender = new MailAddress(str_from_address, str_name);
email_msg.ReplyTo = new MailAddress(str_from_address, str_name);
//The To Email id
email_msg.To.Add(str_to_address);
email_msg.Subject = "My Subject";//Subject of email
email_msg.Body = "This is the body of this message";
//Create an object for SmtpClient class
SmtpClient mail_client = new SmtpClient();
//Providing Credentials (Username & password)
NetworkCredential network_cdr = new NetworkCredential();
network_cdr.UserName = str_from_address;
network_cdr.Password = "gmail_account_password";
mail_client.Credentials = network_cdr;
//Specify the SMTP Port
mail_client.Port = 587;
//Specify the name/IP address of Host
mail_client.Host = "smtp.gmail.com";
//Uses Secure Sockets Layer(SSL) to encrypt the connection
mail_client.EnableSsl = true;
//Now Send the message
mail_client.Send(email_msg);
Console.WriteLine("Email Sent Successfully");
}
catch (Exception ex)
{
//Some error occured
Console.WriteLine(ex.Message.ToString());
}
Console.ReadKey();
}
}
}
[/sourcecode]
Subscribe to:
Post Comments (Atom)
How to enable CORS in Laravel 5
https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...
-
< Requirements Java Development Kit (JDK) NetBeans IDE Apache Axis 2 Apache Tomcat Server Main Topics Setup Development Environ...
-
Download Sourcecode [sourcecode language="csharp"] using System; using System.Collections.Generic; using System.Linq; using System...
No comments:
Post a Comment