From 2dab8149c38c4c79b9f2f7704a061b8522539af2 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Tue, 4 Apr 2023 17:10:27 +0200 Subject: [PATCH] =?UTF-8?q?Pr=C3=BCfung=20beim=20MailItem=20mittels=20TryC?= =?UTF-8?q?ast,=20ob=20Mailobjekt=20nicht=20besch=C3=A4digt=20ist.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERAGAddIn/VERAGAddIn.vbproj | 2 +- VERAGAddIn/rbnVERAG.vb | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) 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