用VB.net發送Email失敗

Clark21 Clark21 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我想用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
急等。請各位大蝦幫幫忙!謝謝了!
...全文
评论 6
收藏 已收藏
分享
返回顶部
Clark21
VB 16,718 成员 110,520 内容