線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1470
推到 Plurk!
推到 Facebook!

如何使用需密碼簽入的SMTP寄信(有帳號)

尚未結案
Brian77
中階會員


發表:8
回覆:114
積分:94
註冊:2002-05-17

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-06-21 14:12:21 IP:61.61.xxx.xxx 未訂閱
已知, 使用 System.Web.Mail.SMTPMail 可以寄信 請問, 遇到需要 ID/Password 的 SMTP 時, 要怎樣子撰寫呢? (具有帳號密碼,但不知道要如何設定給它) 謝謝
andersonhsieh
版主


發表:33
回覆:531
積分:439
註冊:2002-06-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-06-23 16:36:50 IP:220.228.xxx.xxx 未訂閱
引言: 已知, 使用 System.Web.Mail.SMTPMail 可以寄信 請問, 遇到需要 ID/Password 的 SMTP 時, 要怎樣子撰寫呢? (具有帳號密碼,但不知道要如何設定給它) 謝謝
.NET預設的SMTPMail是沒有辦法寄要登入的信 可能要使用thirdparty的物件,如indy現在有for .net版本可以上網去找找下載來試試看 @@~~飛翔在天際的精靈~~@@
------
@@~~飛翔在天際的精靈~~@@
artist1002
高階會員


發表:2
回覆:155
積分:151
註冊:2002-09-26

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-06-24 02:03:02 IP:211.76.xxx.xxx 未訂閱
先聲明一點, 我對.NET程式設計不很熟... 我只花了找資料的時間 發現可以透過組態MailMessage的方式來設定username及password 不過我沒有去試可不可行    
Dim Msg As New System.Web.Mail.MailMessage 
Msg.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpserver" 
Msg.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
Msg.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
Msg.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
Msg.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username" 
Msg.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password" 
Msg.To = "dst@addr.net" 
Msg.From = "src@addr.net" 
Msg.Subject = "Subject" 
Msg.Body = "Message" 
System.Web.Mail.SmtpMail.SmtpServer = "smtpserver" 
System.Web.Mail.SmtpMail.Send(Msg) 
資料來自以下網址 http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=622 http://www.webmasterworld.com/forum47/1782.htm http://blogs.msdn.com/darrenj/archive/2003/10/22/51984.aspx 附註:如果可行,請說一聲...也許有人會用到 發表人 - artist1002 於 2004/06/24 02:04:24
Brian77
中階會員


發表:8
回覆:114
積分:94
註冊:2002-05-17

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-06-24 10:00:43 IP:61.61.xxx.xxx 未訂閱
謝謝兩位指教, 我先試試 artist1002 的方法, 再上來報告結果
Brian77
中階會員


發表:8
回覆:114
積分:94
註冊:2002-05-17

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-06-24 10:57:34 IP:61.61.xxx.xxx 未訂閱
觀察結果: 原本只指定 System.Web.Mail.MailMessage 的 To,From,Subject,Body 等屬性,System.Web.Mail.SmtpMail.Send 時會出現例外: 無法存取 'CDO.Message' 物件 在加上指定 System.Web.Mail.MailMessage.Fields.Item 內數項參數: Item['http://schemas.microsoft.com/cdo/configuration/smtperver']:='SMTP Server'; Item['http://schemas.microsoft.com/cdo/configuration/smtpserverport']:=TObject(integer(25)); Item['http://schemas.microsoft.com/cdo/configuration/sendusing']:=TObject(integer(2)); Item['http://schemas.microsoft.com/cdo/configuration/smtpauthenticate']:=TObject(integer(1)); Item['http://schemas.microsoft.com/cdo/configuration/sendusername']:='信箱ID'; Item['http://schemas.microsoft.com/cdo/configuration/sendpassword']:='信箱密碼'; 即可順利寄信. 其中前三項可以省略, 只要加上後三項即可. 之前查錯方向了.. 謝謝指教
系統時間:2024-05-21 15:50:09
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!