【发布时间】:2018-07-06 03:42:20
【问题描述】:
//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;
}
}
}
【问题讨论】:
-
提示,在这里闲逛的人都是经验丰富的程序员,我们大多数人都有严重的强迫症,讨厌乱七八糟的代码,并且一生都在努力让事情看起来整洁优雅。如果你问一个问题,花 5 分钟整理你的代码以便按下大按钮,你会发现它总是值得的