用VB.net發送Email失敗

Clark21 2007-08-17 03:46:56
我想用VB.net發送Email,一併cc副本給使用者所留的email,但是收不到郵件。請問是怎麼回事?下面是代碼︰
Public Function SenExportFile(ByVal LSTR_EmailAddress As String, ByVal LSTR_AttachPath As String, ByVal LSTR_ExportContent As String, ByVal LSTR_Subject As String, ByVal LSTR_From As String, ByVal LSTR_Cc As String) As String Implements IBU_TEPS.SenExportFile
'*****必要宣告*****
Dim LSTR_ClassName As String
Dim LSTR_MethodName As String
Dim LSTR_MethodID As String = "07"

Dim LSTR_LogFile As String
'*****額外宣告*****
Dim SMail As System.Web.Mail.SmtpMail
Dim message As New Web.Mail.MailMessage
Dim attachFile As MailAttachment
Dim attachFile1 As MailAttachment
Dim attachFile2 As MailAttachment

Dim LSTR_XlsData As String
Dim LSTR_FileName As String
Dim LOBJ_Component As Object
Dim GCST_TEPSReportPath As String

GCST_TEPSReportPath = ITG.Common.GetProfileString(ITG.Common.GCST_EnvParameter, "TEPSReportPath", "", ITG.Common.GCST_IniFileName)
Try
LSTR_ClassName = "ITG.BU_TEPS"
LSTR_MethodName = "SenExportFile"
LSTR_LogFile = LSTR_ClassName & "_" & LSTR_MethodName & ".log"
ITG.Common.LogFile(LSTR_LogFile)
ITG.Common.LogFile(LSTR_LogFile, "LSTR_EmailAddress", LSTR_EmailAddress)
ITG.Common.LogFile(LSTR_LogFile, "LSTR_AttachPath", LSTR_AttachPath)
ITG.Common.LogFile(LSTR_LogFile, "LSTR_ExportContent", LSTR_ExportContent)
ITG.Common.LogFile(LSTR_LogFile, "LSTR_EmailAddress", LSTR_EmailAddress)
ITG.Common.LogFile(LSTR_LogFile, "LSTR_From", LSTR_From)
ITG.Common.LogFile(LSTR_LogFile, "LSTR_Cc", LSTR_Cc)

message.To = CStr(LSTR_EmailAddress)
message.From = CStr(LSTR_From)
If CStr(LSTR_Cc) <> "" Then
message.Cc = CStr(LSTR_Cc)
End If
message.Body = LSTR_ExportContent
message.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8")
message.BodyFormat = Web.Mail.MailFormat.Html
message.Priority = Web.Mail.MailPriority.High
message.Subject = LSTR_Subject

Call SMail.Send(message)

SenExportFile = GCST_CorrectRC + GCST_TEPSReportPath + LSTR_AttachPath
ITG.Common.LogFile(LSTR_LogFile, SenExportFile)
ContextUtil.SetComplete()
Catch Exception As System.Exception
SenExportFile = GCST_NotCorrectRC + Exception.Message
ITG.Common.LogFile(LSTR_LogFile, SenExportFile)
If Not LOBJ_Component Is Nothing Then
LOBJ_Component = Nothing
End If
ContextUtil.SetAbort()
Throw Exception
Finally
If Not LOBJ_Component Is Nothing Then
LOBJ_Component = Nothing
End If
End Try
End Function
急等。請各位大蝦幫幫忙!謝謝了!
...全文
173 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
war_3 2007-12-29
  • 打赏
  • 举报
回复
现在的邮件服务器大都需要验证,比如使用163服务器,必须验证用户名跟密码。不过我搜了好长时间,都没有找到关于验证的代码
Clark21 2007-08-20
  • 打赏
  • 举报
回复
請問,誰有vb.net 2005得msdn?寄件者要求是使用者輸入的姓名,但vb.net2003只能是電子郵件地址
fuyiyong 2007-08-20
  • 打赏
  • 举报
回复
就是啊,JMail超方便
lgx1972 2007-08-18
  • 打赏
  • 举报
回复
真够麻烦的,还不如用Jmail组件,编程超方便,又不容易出错。

16,556

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧