如果我的电脑上没有安装 IIS/SMTP 代理,是否可以发送电子邮件?
Is it possible to send email if IIS/SMTP agents are not installed on my pc?
如果我的本地电脑没有安装 IIS/SMTP 代理,是否可以使用 asp.net 发送电子邮件。 PS 我正在使用 Windows 7
我试过很多代码:这就是我目前使用的
Dim message As New MailMessage("abc@xyz.com", "pqr.@xyz.com", "SUB: Testing email", "SENDING EMAIL VAI ASP.NET")
Dim emailClient As New SmtpClient("XXX.XXX.XXX.XXX")
emailClient.Send(message)
MsgBox("Message Sent")
错误信息:
由于目标机器主动拒绝,无法建立连接
[WebException: 无法连接到远程服务器]
[SmtpException: 发送邮件失败。]
SMTP 不必安装在同一台服务器上,但您的 IP 地址应该被允许。
您也可以将 Gmail 与您自己的帐户用作您的 SMTP 服务器。
这是我正在使用的代码。 (它是 C#,但你可以转换它)
static readonly string EmailSendFrom = System.Web.Configuration.WebConfigurationManager.AppSettings["emailSendFrom"];
static readonly string EmailDisplayName = System.Web.Configuration.WebConfigurationManager.AppSettings["emailDisplayName";
static readonly string EmailPassword = System.Web.Configuration.WebConfigurationManager.AppSettings["emailPassword"];
public static void SendEmail(string emailHtmlContent, string emailRecipients, string emailSubject, bool addBbc)
{
var @from = EmailSendFrom;
var to = emailRecipients;
var mail = new MailMessage();
mail.To.Add(to);
mail.From = new MailAddress(@from, EmailDisplayName, System.Text.Encoding.UTF8);
mail.Subject = emailSubject;
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = emailHtmlContent;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
var client = new SmtpClient
{
Credentials = new System.Net.NetworkCredential(@from, EmailPassword),
Port = 587,
Host = "myhost.name.co.il",
EnableSsl = false
};
client.Send(mail);
}
如果我的本地电脑没有安装 IIS/SMTP 代理,是否可以使用 asp.net 发送电子邮件。 PS 我正在使用 Windows 7
我试过很多代码:这就是我目前使用的
Dim message As New MailMessage("abc@xyz.com", "pqr.@xyz.com", "SUB: Testing email", "SENDING EMAIL VAI ASP.NET")
Dim emailClient As New SmtpClient("XXX.XXX.XXX.XXX")
emailClient.Send(message)
MsgBox("Message Sent")
错误信息:
由于目标机器主动拒绝,无法建立连接
[WebException: 无法连接到远程服务器]
[SmtpException: 发送邮件失败。]
SMTP 不必安装在同一台服务器上,但您的 IP 地址应该被允许。
您也可以将 Gmail 与您自己的帐户用作您的 SMTP 服务器。
这是我正在使用的代码。 (它是 C#,但你可以转换它)
static readonly string EmailSendFrom = System.Web.Configuration.WebConfigurationManager.AppSettings["emailSendFrom"];
static readonly string EmailDisplayName = System.Web.Configuration.WebConfigurationManager.AppSettings["emailDisplayName";
static readonly string EmailPassword = System.Web.Configuration.WebConfigurationManager.AppSettings["emailPassword"];
public static void SendEmail(string emailHtmlContent, string emailRecipients, string emailSubject, bool addBbc)
{
var @from = EmailSendFrom;
var to = emailRecipients;
var mail = new MailMessage();
mail.To.Add(to);
mail.From = new MailAddress(@from, EmailDisplayName, System.Text.Encoding.UTF8);
mail.Subject = emailSubject;
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = emailHtmlContent;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
var client = new SmtpClient
{
Credentials = new System.Net.NetworkCredential(@from, EmailPassword),
Port = 587,
Host = "myhost.name.co.il",
EnableSsl = false
};
client.Send(mail);
}