ProcessAfterWrite

Add-in Express™ Support Service
That's what is more important than anything else

ProcessAfterWrite
 
Byung Kun Kim


Guest


Why access to mailitem's attributes failed on ProcessAfterWrite?


    Public Overrides Sub ProcessAfterWrite()
        If TypeOf Me.ItemObj Is Outlook.MailItem Then
            Dim mail As Outlook.MailItem = TryCast(Me.ItemObj, Outlook.MailItem)
            MessageBox.Show(mail.MessageClass.ToString()) 'Succeed
            MessageBox.Show(mail.Subject) 'Failed
        End If
    End Sub


I want to know changed(or assigned) EntryID when saved, not saved by my code.
Posted 09 Nov, 2016 12:14:53 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Byung,

Would it work if you use System.Diagnostic.Debug.WriteLine instead of MessageBox.Show?


Andrei Smolin
Add-in Express Team Leader
Posted 10 Nov, 2016 06:36:24 Top
Byung Kun Kim


Guest


Yes, same error. LF() is my logging function calling log4net.


    Public Overrides Sub ProcessAfterWrite()
        If TypeOf Me.ItemObj Is Outlook.MailItem Then
            Dim mail As Outlook.MailItem = TryCast(Me.ItemObj, Outlook.MailItem)
            LF("mail.MessageClass: {0}", AA(mail.MessageClass)) 'Succeed
            LF("mail.Subject: {0}", AA(mail.Subject)) 'Failed
        End If
    End Sub





Detailed technical information follows: 
---
(Inner Exception)

Assembly Codebase:     file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.Outlook/15.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Outlook.dll
Assembly Full Name:    Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
Assembly Version:      15.0.0.0

Exception Source:      Microsoft Outlook
Exception Type:        System.Runtime.InteropServices.COMException
Exception Message:     항목의 속성 및 메서드는 이 이벤트 프로시저 내에서 사용할 수 없습니다.
Exception Target Site: get_Subject

---- Stack Trace ----
   Microsoft.Office.Interop.Outlook._MailItem.get_Subject()
       Microsoft.Office.Interop.Outlook.dll: N 00000 (0x0) JIT 
   OutlookAddin.ItemEvents.ProcessAfterWrite()
       ItemEvents(뉴).vb: line 0042, col 13, IL 0081 (0x51)
   AddinExpress.MSO.ADXOlItemEvents_10_SinkHelper.AddinExpress.MSO.IOutlookItemEvents_10.AfterWrite()
       Microsoft.Office.Interop.Outlook.dll: N 0000 (0x0) IL 



(Outer Exception)
Date and Time:         2016-11-11 오전 12:31:09

Application Domain:    c:LDriveClientLibOutlookAddininDebug
Assembly Codebase:     file:///C:/Windows/assembly/GAC_MSIL/AddinExpress.MSO.2005/8.3.4393.0__4416dd98f0861965/AddinExpress.MSO.2005.dll
Assembly Full Name:    AddinExpress.MSO.2005, Version=8.3.4393.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version:      8.3.4393.0

Exception Source:      
Exception Type:        AddinExpress.MSO.ADXExternalException
Exception Message:     An error has occurred in the code of the add-in.

---- Stack Trace ----


Posted 10 Nov, 2016 10:47:31 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Byung,

The exception message is "The properties and methods of the item are not available within this event procedure". At https://msdn.microsoft.com/en-us/library/office/ff869691.aspx, they list the properties that are accessible in this event:


  • Class
  • MessageClass
  • MAPIOBJECT



Andrei Smolin
Add-in Express Team Leader
Posted 11 Nov, 2016 01:06:22 Top