Prüfung beim MailItem mittels TryCast, ob Mailobjekt nicht beschädigt ist.

This commit is contained in:
2023-04-04 17:10:27 +02:00
parent 834ef647d0
commit 2dab8149c3
2 changed files with 14 additions and 5 deletions

View File

@@ -36,7 +36,7 @@
<PublishUrl>\\ftps.verag.ag\g\ftp\programme\VERAGAddin\</PublishUrl>
<InstallUrl>http://ftps.verag.ag/VERAGAddin/</InstallUrl>
<TargetCulture>de</TargetCulture>
<ApplicationVersion>1.0.1.98</ApplicationVersion>
<ApplicationVersion>1.0.1.99</ApplicationVersion>
<AutoIncrementApplicationRevision>true</AutoIncrementApplicationRevision>
<UpdateEnabled>true</UpdateEnabled>
<UpdateInterval>0</UpdateInterval>

View File

@@ -106,12 +106,21 @@ Public Class AVISO_Mail_Functions
Dim explorer As Outlook.Explorer = Globals.ThisAddIn.Application.ActiveExplorer
Dim selection As Outlook.Selection = explorer.Selection
If selection.Count > 0 Then
Dim selectedItem = selection(1)
Dim selectedItem As Object = selection(1)
Dim result = TryCast(selectedItem, Outlook.MailItem)
If result IsNot Nothing Then
Dim mailItem As Outlook.MailItem = selectedItem
mailItem = DirectCast(mailItem, Outlook.MailItem)
addMailToAviso(mailItem, isFormular)
Else
MsgBox("Die markierte Email kann nicht verarbeitet werden!" & vbNewLine & "Bitte andere Mail verwenden.")
End If
End If
Catch ex As Exception
MsgBox(ex.Message & ex.StackTrace)
End Try