//in class a create object to classb and send data to classb sendmail method
class a{
classb b=new classb();
b.sendmail(jsonData);
}
// classb class recevie data and send the mail
class classb(){
//method
public void sendmail(classname obj){
string to = "test.123@gmail.com";
string from = "test@mail";
MailMessage message = new MailMessage(from, to);
message.Subject = "Demo Requsted from User";
message.Body = mailbody;
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
// where to give azure api key .i have only send-grid api key .please help me
var smtp = new SmtpClient
{
Host = "smtp.sendgrid.net",// azure server
Port = 587,
EnableSsl = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = true,
Credentials = new System.Net.NetworkCredential("mail", "pwd")
};
try
{
smtp.Send(message);
}
catch (Exception ex)
{
throw ex;
}
}
}