转换为system.net.mail.mailMessage错误

时间:2019-04-22 12:38:48

标签: c#

我实际上是在Visual Studio中尝试使用MVC创建带有验证邮件的注册页面,但是在这里向我发送消息

  

错误:“ RandLform.Controllers.MailMessage”到“ System.Net.Mail.MailMessage” RandLform

public void SendVerficationLinkEmail(string emailID, string activationCode)
{
    var VerifyUrl = "/User/VerifyAccount/" + activationCode;

    var link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, VerifyUrl);

    var fromEmail = new MailAddress("lokeshkingdom4u@gmail.com", "Lokesh Pladugula");

    var toEmail = new MailAddress(emailID);

    var fromEmailPassword = "paisa007";

    string subject = "Account created Succesfully!";

    string body = "<br/>To verify your account, click on below link.<br/><br/> "+" <a href = "+link+"> "+link+"</a>";

    var smtp = new SmtpClient
    {
        Host = "smtp.gmail.com",
        Port = 587,
        EnableSsl = true,
        DeliveryMethod = SmtpDeliveryMethod.Network,
        UseDefaultCredentials = false,
        Credentials = new NewNetworkCredential(fromEmail.Address, fromEmailPassword)

    };

    using (var message = new MailMessage(fromEmail, toEmail)
    {
        Subject = subject,
        Body = body,
        IsBodyHtml = true
    }) 
    smtp.Send(message);
}

1 个答案:

答案 0 :(得分:0)

Lokesh Paladugula,

我建议您更改电子邮件帐户的密码。

我不确定这是否是实际错误,请发送适当的错误。