Local-host を使用してメール ID やパスワードなどのメール認証情報を使用せずにメールを送信するにはどうすればよいですか?
2 に答える
0
そのためにこのコードを使用し、
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
MailAddress SendFrom = new MailAddress(txtFrom.Text);
MailAddress SendTo = new MailAddress(txtTo.Text);
MailMessage MyMessage = new MailMessage(SendFrom, SendTo);
MyMessage.Subject = txtSubject.Text;
MyMessage.Body = txtBody.Text;
Attachment attachFile = new Attachment(txtAttachmentPath.Text);
MyMessage.Attachments.Add(attachFile);
SmtpClient emailClient = new SmtpClient(txtSMTPServer.Text);
emailClient.Send(MyMessage);
litStatus.Text = "Message Sent";
}
catch (Exception ex)
{
litStatus.Text=ex.ToString();
}
}
于 2013-10-23T12:56:23.120 に答える
0
c:/ ドライブに「maildrop」というフォルダーを作成し、Web.config ファイルで次のように使用します。
<mailSettings>
<smtp deliveryMethod='SpecifiedPickupDirectory'>
<specifiedPickupDirectory pickupDirectoryLocation="c:\maildrop" />
</smtp>
</mailSettings>
詳しくは:
認証情報なしの外部配信の場合:
<mailSettings>
<smtp from="info@mysite.com">
<network host="smtp.myhost.com"/>
</smtp>
</mailsettings>
于 2012-05-30T13:39:01.013 に答える