我想在用户第一次注册时将注册链接发送到 Gmail 帐户,我的意思是检查用户电子邮件地址的真实性。我已经实现了这一点,但我的问题是用户也没有得到任何链接和消息正文。如果我在我的函数中定义这两个,它会给我错误。这是我的函数,它给了我以下错误:
“非静态字段、方法或属性 'System.Web.Mvc.Controller.HttpContext.get' 需要对象引用”和 message.body="" 的语法错误。
我该怎么办?
public class EmailManager
{
private const string EmailFrom = "noreplay@gmail.com";
public static void SendConfirmationEmail(string userName)
{
var user = Membership.GetUser(userName.ToString());
var confirmationGuid = user.ProviderUserKey.ToString();
//var verifyUrl = HttpContext.Current.Request.Url.GetLeftPart
// (UriPartial.Authority) + "/Account/Verify/" + confirmationGuid;
using (var client = new SmtpClient())
{
using (var message = new MailMessage(EmailFrom, user.Email))
{
message.Subject = "Please Verify your Account";
// message.Body = "To verify your account, please click the following link:"
//+ "<a href=\"" + verifyUrl + "\" target=\"_blank\">" + verifyUrl + "
//+"</a></p><div>Best regards,</div><div>Someone</div><p>Do not forward "
//+"this email. The verify link is private.</p></body></html>";
message.IsBodyHtml = true;
client.EnableSsl = true;
client.Send(message);
};
};
}
}
请帮助我。