I have send mail office outlook.
Please help me solve it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
using System.Text;
public partial class Default12 : System.Web.UI.Page
{
public class OutlookDotComMail
{
string _sender = "";
string _password = "";
string _domain = "";
public OutlookDotComMail(string sender, string password)
{
_sender = sender;
_password = password;
}
public void SendMail(string recipient, string subject, string message)
{
SmtpClient client = new SmtpClient();
client.Host = "mail.globaltechnopartners.com";
client.Port = 465;
client.UseDefaultCredentials = false;
// client.DeliveryMethod = SmtpDeliveryMethod.Network;
System.Net.NetworkCredential credentials =
new System.Net.NetworkCredential(_sender, _password, _domain);
var creds = CredentialCache.DefaultCredentials;
client.EnableSsl = true;
client.Credentials = credentials;
try
{
var mail = new MailMessage(_sender.Trim(), recipient.Trim());
mail.Subject = subject;
mail.Body = message;
client.Send(mail);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
}
internal void SendMail(string email)
{
throw new NotImplementedException();
}
}
protected void Page_Load(object sender, EventArgs e)
{
string mailuserpass = "*******";
var sender1 = new OutlookDotComMail(mailuser, mailuserpass);
}
}