diff --git a/VERAGAddIn/VERAGAddIn.vbproj b/VERAGAddIn/VERAGAddIn.vbproj
index 76f1e9c..134007d 100644
--- a/VERAGAddIn/VERAGAddIn.vbproj
+++ b/VERAGAddIn/VERAGAddIn.vbproj
@@ -36,7 +36,7 @@
\\ftps.verag.ag\g\ftp\programme\VERAGAddin\
http://ftps.verag.ag/VERAGAddin/
de
- 1.0.1.98
+ 1.0.1.99
true
true
0
diff --git a/VERAGAddIn/rbnVERAG.vb b/VERAGAddIn/rbnVERAG.vb
index 88cba67..db6cb07 100644
--- a/VERAGAddIn/rbnVERAG.vb
+++ b/VERAGAddIn/rbnVERAG.vb
@@ -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 mailItem As Outlook.MailItem = selectedItem
- mailItem = DirectCast(mailItem, Outlook.MailItem)
+ Dim selectedItem As Object = selection(1)
- addMailToAviso(mailItem, isFormular)
+ 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