用VB.net發送Email失敗
我想用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
急等。請各位大蝦幫幫忙!謝謝了!