在ASP.NET中向Hotmail或Outlook发送电子邮件

时间:2017-09-06 15:04:39

标签: asp.net vb.net

我试图在asp.net中发送电子邮件,它可以查找并发送电子邮件给GMAIL和YAHOO邮件,但不能使用HOTMAIL或OUTLOOK帐户。 这是代码......

Dim pass As String = RandomPassword.Generate(8, 10)
ta.insertuser(txtuser.Text, pass, txtfname.Text, txtlname.Text, txtemail.Text, droprole.SelectedValue, radiostatus.SelectedValue, DateTime.Now())

Dim senderma As New MailAddress("client@karacode.ir", "karacode")
Dim recipientma As New MailAddress(txtemail.Text)
Dim mm As New MailMessage(senderma, recipientma) With {
    .Subject = "Account Details",
    .SubjectEncoding = System.Text.Encoding.UTF8,
    .Body = "<div style='font-family: tahoma; font-size: 10pt; padding: 1em; direction:rtl; text-align: justify; line-height: 2;'>" & "Dear User" & " " & txtfname.Text & " " & txtlname.Text & "<br />" & "You're most welcom to KARACODE" & "<br /><br />" & "Your account information<br /><br />" & "Username : <br />" & txtuser.Text & "<br /><br />" & "Password : <br />" & pass & "</div>",
    .BodyEncoding = System.Text.Encoding.UTF8,
    .IsBodyHtml = True
}
Dim cred As New System.Net.NetworkCredential With {
    .UserName = "client@karacode.ir",
    .Password = "Client164418054545"
}
Dim smtp As New SmtpClient With {
    .Host = "webmail.karacode.ir",
    .EnableSsl = False,
    .UseDefaultCredentials = True,
    .Credentials = cred,
    .Port = 25
}
smtp.Send(mm)

请提供解决问题的提示。 很多,谢谢

0 个答案:

没有答案