我知道这个问题已经存在,但我阅读了所有这些问题,但没有找到答案。这是我的SendEmail方法。指定的字符串不是电子邮件地址所需的格式,不知道什么是错的?
public bool SendEmail(PostEmail postEmail)
{
if (string.IsNullOrEmpty(postEmail.emailTo))
{
return false;
}
using (SmtpClient smtpClient = new SmtpClient())
{
using (MailMessage message = new MailMessage())
{
message.Subject = postEmail.subject == null ? "" : postEmail.subject;
message.Body = postEmail.body == null ? "" : postEmail.body;
message.IsBodyHtml = postEmail.isBodyHtml;
message.To.Add(new MailAddress(postEmail.emailTo));
try
{
smtpClient.Send(message);
return true;
}
catch (Exception exception)
{
//Log the exception to DB
throw new FaultException(exception.Message);
}
}
}
我有一个电子邮件 地址
我不知道什么可能是错误的所要求的形式问题
此错误的指定的字符串不是。请帮忙吗?
好吧!你的“SendEmail”不是一个类! – deeiip
“postEmail.emailTo”中的值是否为有效的电子邮件地址?你是否指定了“发件人”地址? –
错误信息不能更清楚。 – jsanalytics