2012-05-30 74 views

回答

0

只需創建一個名爲 「信箱」 在你的文件夾C:/驅動器,並使用在Web.config文件如下:

<mailSettings> 
    <smtp deliveryMethod='SpecifiedPickupDirectory'> 
     <specifiedPickupDirectory pickupDirectoryLocation="c:\maildrop" /> 
    </smtp> 
</mailSettings> 

的更多信息:

http://weblogs.asp.net/gunnarpeipman/archive/2010/05/27/asp-net-using-pickup-directory-for-outgoing-e-mails.aspx

對於外部無憑證遞送:

<mailSettings> 
    <smtp from="[email protected]"> 
     <network host="smtp.myhost.com"/> 
    </smtp> 
</mailsettings> 
+0

使用此代碼我可以將郵件保存在我的個人計算機或服務器中,但我無法將其發送到任何特定的電子郵件地址。你能告訴我誰能做到這一點?可能嗎? –

+0

回答更新:) – IrishChieftain

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(); 
    } 
    } 
相關問題