我有一个电子邮件按钮,但我无法让它工作,它正在做notng,我真的不知道为什么。
`Private Sub Button2_Click_1(发件人为对象,e为EventArgs)处理tbsEmailRenewal.Click On Error GoTo Err_cmdEMailInvoice_Click
If tbsEmailRenewal.Tag = "" Then Exit Sub
' Create Report
Dim ListReport = New FastReport.Report
ListReport.Load(My.Settings.SystemPath & "\Reports\EmailRenewalLetter.frx")
ListReport.SetParameterValue("CRMConnectionString", "Data Source=" & My.Settings.SQLServer & ";AttachDbFilename=;Initial Catalog=ICOM.Database;Integrated Security=False;Persist Security Info=False;User ID=CRMUser;Password=S0rtmypc!")
ListReport.SetParameterValue("MemberID", objMember.MemberID)
ListReport.Prepare()
' Create Export File
Dim PDFExport As FastReport.Export.Pdf.PDFExport = New FastReport.Export.Pdf.PDFExport
ListReport.Export(PDFExport, My.Settings.SystemPath & "Reports\EMailReport" & Format(objMember.MemberID, "00000") & ".pdf")
' Create EMail
Dim objOutlook As Object
Dim objMailMessage As Outlook.MailItem
objOutlook = CreateObject("Outlook.Application")
objMailMessage = objOutlook.CreateItem(0)
With objMailMessage
.To = txtEmailAddess1.Text
.Subject = "Renewal For " & lblMemberIDValue.Text
.Attachments.Add(My.Settings.SystemPath & "Reports\EMailReport" & Format(objMember.MemberID, "00000") & ".pdf")
.Display()
.Save()
.Close(Outlook.OlInspectorClose.olDiscard)
End With
objMailMessage = Nothing
objOutlook = Nothing
' Log It
Dim sMessage As String
sMessage = Replace(">" & Format(objMember.MemberID, "00000") & " to " & tbsEmailRenewal.Tag, "'", "`")
WriteAuditLogRecord(Me.Name, "tbsEmailRenewal.Click", "INFO", sMessage)
MsgBox("Email has been saved as a Draft", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ICOM - Action Confirmed")
Err_cmdEMailInvoice_Click:
If Err.Number <> 0 Then
sErrDescription = Err.Description
WriteAuditLogRecord(Me.Name, "cmdEMailInvoice_Click", "Error", sErrDescription)
MsgBox("System Error occurred" & Chr(13) & "tbsEmailRenewal.Click" & Chr(13) & sErrDescription, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "AztecCRM - Error Reporting")
End If
End Sub`
答案 0 :(得分:0)
你确定tbsEmailRenewal.Tag不是空的吗?
If tbsEmailRenewal.Tag = "" Then Exit Sub