Byung Kun Kim
Guest
|
I added some customUserProperty to outlook drafts mail.
I want to do some additional tasks when user deletes the drafts mail, reading my added customproperty and do some tasks with the data in userproperty.
How can I achieve this? OutlookItemsEvents class doesn't seem to have ItemObj like arguments.
Can I know EntryID when mailitem deleted?
Perhaps I'm able to know drafts mail is moved to deleteItems folder by 'ProcessBeforeItemMove'. but how do I know mailitem deleted from deleteditems?
Public Overrides Sub ItemRemove(ByVal SourceFolder As Object)
'TODO: Add some code
Dim outlookApp As Outlook._Application = DirectCast(Me.[Module], AddinModule).OutlookApp
Dim targetFolder As Outlook.MAPIFolder = DirectCast(Me.FolderObj, Outlook.MAPIFolder)
Dim journalItem As Outlook._JournalItem = Nothing
'Try
' journalItem = DirectCast(outlookApp.CreateItem(Outlook.OlItemType.olJournalItem), Outlook._JournalItem)
' journalItem.Subject = [String].Format("You've removed items from {0}", targetFolder.FolderPath)
' journalItem.Save()
'Finally
' If journalItem IsNot Nothing Then
' Marshal.ReleaseComObject(journalItem)
' End If
'End Try
End Sub
public override void ProcessBeforeItemMove(object item, object moveTo, AddinExpress.MSO.ADXCancelEventArgs e)
{
if (item is Outlook._ContactItem)
{
Outlook._ContactItem movedContact = (Outlook._ContactItem)item;
Outlook._Application outlookApp = ((AddinModule)this.Module).OutlookApp;
Outlook._JournalItem journalItem = null;
try
{
journalItem = (Outlook._JournalItem)outlookApp.CreateItem(Outlook.OlItemType.olJournalItem);
if (moveTo != null)
{
Outlook.MAPIFolder targetFolder = (Outlook.MAPIFolder)moveTo;
journalItem.Subject = String.Format("You've moved {0} to {1}",
movedContact.FullName, targetFolder.FolderPath);
Marshal.ReleaseComObject(moveTo);
}
else
{
journalItem.Subject = String.Format("You've permanently deleted {0}",
movedContact.FullName);
}
journalItem.Save();
}
finally
{
if (journalItem != null)
Marshal.ReleaseComObject(journalItem);
}
}
}
|
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
|
Byung Kun Kim
Guest
|
Thank you for your favorable reply, Andrei. I'll study the Properties.
Andrei said:
which is null if the item is "hard" deleted (via Shift+Delete).
Does the same event occurs when user emptied deletedItems folder (via right click context menu) or just delete a mail(via non-Shift + Delete)? |
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
You are welcome!
Andrei Smolin
Add-in Express Team Leader |
|