Umgebung: VS 2010 /VB - Projekt -> Windows Forms
Outlook 2003
Bei dem automatischen Versand von Emails bekomme ich denfolgenden Fehler:
13 Unable to cast object of type 'System.__ComObject' to type 'Microsoft.Office.Interop.Outlook.ApplicationClass '.
Folgender Quellcode:
Kann mir jemand einen Tipp geben, was ich falsch mache? Danke schon mal
Outlook 2003
Bei dem automatischen Versand von Emails bekomme ich denfolgenden Fehler:
13 Unable to cast object of type 'System.__ComObject' to type 'Microsoft.Office.Interop.Outlook.ApplicationClass '.
Folgender Quellcode:
Code:
Public Shared Sub SendEmailFromAccount(ByVal subject As String, ByVal body As String, ByVal recipients As String, ByVal smtpAddress As String, ByVal attm() As String, ByVal count_attm As Integer, Optional ByVal flag_display_send As String = "D") Try Dim objOutlook As New Outlook.Application objOutlook.CreateObject("Outlook.Application") Dim objOutlookMsg As Outlook.MailItem ' === objOutlookMsg = objOutlook.CreateItem(Outlook.OlItemType.olMailItem) objOutlookMsg = objOutlook.CreateItem(0) With objOutlookMsg .To = recipients .CC = "" .BCC = "" .Subject = subject .Body = body 'Attachment erstellen If count_attm > 0 Then For i = 0 To count_attm - 1 objOutlookMsg.Attachments.Add(attm(i)) Next End If Select Case flag_display_send Case "D" '//am Bildschirm anzeigen .Display() Case "S" .Send() If debugshow = "Y" Then MsgBox(" send") End Select End With 'objOutlook = Nothing Catch ex As Exception tools.show_errors(ex, "mailtool_func", "SendEmailFromAccount") 'MsgBox(Err.Number & " " & Err.Description) globfunction.write_log("Error (" & mailtyp & "/" & subject & "/" & recipients & "): " & Err.Number & " " & Err.Description, logfile) End Try End Sub
Comment