|
Thanasis Boukouvalas
Posts: 40
Joined: 2006-06-17
|
Hi
I'm using ProcessItemAdd of ADXOutlookItemsEvents in order to change FlagIcon add add some MailItem.UserProperties in newly added mails in a specific folder.
After doing the above, I call MailItem.Save and sometimes my changes are kept but some other doesnt.
I've notice that when I move a mail from other folder to that specific folder, everything is OK.
But when I copy a mail from other folder to that specific folder, the MailItem.Save seems doesnt works. |
|
Posted 20 Sep, 2006 09:26:37
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
|
Posted 21 Sep, 2006 06:37:47
|
|
Top
|
|
Thanasis Boukouvalas
Posts: 40
Joined: 2006-06-17
|
Hi Sergey
Your example works fine on my PC.
I dont know how can I send to you a sample project that illustrates the problem in order to test it on your PC, so, I send you the code.
Imports System.Runtime.InteropServices
Imports System.ComponentModel
Imports Outlook = Microsoft.Office.Interop.Outlook
'Add-in Express Add-in Module
<GuidAttribute("2DC698E6-9E5F-4CF7-8506-88CFB1BC5EAB"), ProgIdAttribute("MailItemSaveTest.AddinModule"), RunInstaller(True)> _
Public Class AddinModule
Inherits AddinExpress.MSO.ADXAddinModule
#Region " Component Designer generated code. "
'Required by designer
Private components As System.ComponentModel.IContainer
'Required by designer - do not modify
'the following method
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
'
'AddinModule
'
Me.AddinName = "MailItemSaveTest"
Me.SupportedApps = CType(( _
AddinExpress.MSO.ADXOfficeHostApp.ohaOutlook _
), AddinExpress.MSO.ADXOfficeHostApp)
End Sub
#End Region
#Region " ADX automatic code "
'Required by Add-in Express - do not modify
'the methods within this region
Public Overrides Function GetContainer() As System.ComponentModel.IContainer
If components Is Nothing Then
components = New System.ComponentModel.Container
End If
GetContainer = components
End Function
<ComRegisterFunctionAttribute()> _
Public Shared Sub AddinRegister(ByVal t As Type)
AddinExpress.MSO.ADXAddinModule.ADXRegister(t)
End Sub
<ComUnregisterFunctionAttribute()> _
Public Shared Sub AddinUnregister(ByVal t As Type)
AddinExpress.MSO.ADXAddinModule.ADXUnregister(t)
End Sub
Public Overrides Sub UninstallControls()
MyBase.UninstallControls()
End Sub
#End Region
Public Sub New()
MyBase.New()
'This call is required by the Component Designer
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
Public ReadOnly Property OutlookApp() As Outlook._Application
Get
Return CType(HostApplication, Outlook._Application)
End Get
End Property
Private Sub AddinModule_AddinStartupComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.AddinStartupComplete
Dim itemsEvents As New OutlookItemsEventsClass1(Me)
itemsEvents.ConnectTo(AddinExpress.MSO.ADXOlDefaultFolders.olFolderDrafts, True)
End Sub
End Class
'Add-in Express Outlook Items Events Class
Public Class OutlookItemsEventsClass1
Inherits AddinExpress.MSO.ADXOutlookItemsEvents
Public Sub New(ByVal ADXModule As AddinExpress.MSO.ADXAddinModule)
MyBase.New(ADXModule)
End Sub
Public Overrides Sub ProcessItemAdd(ByVal Item As Object)
If Not TypeOf Item Is Outlook.MailItem Then Exit Sub
Dim mail As Outlook.MailItem = CType(Item, Outlook.MailItem)
Dim filename As String = IO.Path.GetTempFileName
mail.SaveAs(filename)
Dim entersoftCRMregID As String = EntersoftCRMserver.RegisterEmail(filename)
mail.UserProperties.Add("EntersoftCRMregID", Outlook.OlUserPropertyType.olText, True).Value = entersoftCRMregID
mail.FlagIcon = Outlook.OlFlagIcon.olPurpleFlagIcon
mail.Save()
End Sub
Public Overrides Sub ProcessItemChange(ByVal Item As Object)
'TODO: Add some code
End Sub
Public Overrides Sub ProcessItemRemove()
'TODO: Add some code
End Sub
End Class
Public Class EntersoftCRMserver
Public Shared Function RegisterEmail(ByVal mailFilename As String) As String
'process email
'...
IO.File.Delete(mailFilename)
'return registration ID
Return Guid.NewGuid.ToString
End Function
End Class
|
|
Posted 21 Sep, 2006 07:35:47
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Thanasis.
You have the incorrect code in the AddinStartupComplete event handler.
Try to change it as shown below.
Private itemsEvents As OutlookItemsEventsClass1 = Nothing
Private Sub AddinModule_AddinStartupComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.AddinStartupComplete
itemsEvents As New OutlookItemsEventsClass1(Me)
itemsEvents.ConnectTo(AddinExpress.MSO.ADXOlDefaultFolders.olFolderDrafts, True)
End Sub
End Class
Private Sub AddinModule_AddinBeginShutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.AddinBeginShutdown
itemsEvents.Dispose()
End Sub
|
|
Posted 21 Sep, 2006 09:26:34
|
|
Top
|
|
Thanasis Boukouvalas
Posts: 40
Joined: 2006-06-17
|
When I found that I cannot send you my test project as attachment in this forum, I was in a hurry to "packed" it as text and that was caused this error you've noticed.
In my original test project of course itemEvents are not a local variable.
So, this is not the problem.
Try to do the correction you've write and then I hope you'll see that when you drag and drop to Drafts folder en email, everything is OK.
But when you ctrl+drag (copy) an email to Drafts folder then MailItem.Save does not save the changes. |
|
Posted 21 Sep, 2006 10:01:10
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Thanasis, I have sent you an example based on your code.
It works fine on my PC when I Ctrl+Drag an email.
Could you please check it? |
|
Posted 21 Sep, 2006 16:16:24
|
|
Top
|
|
Thanasis Boukouvalas
Posts: 40
Joined: 2006-06-17
|
Hi Sergey
I dont see the example here and I have not receive any mail from you.
Where can I find it? |
|
Posted 22 Sep, 2006 02:38:38
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Thanasis.
Does your email registered on our forum work? |
|
Posted 22 Sep, 2006 06:23:40
|
|
Top
|
|
Thanasis Boukouvalas
Posts: 40
Joined: 2006-06-17
|
In my "Profile" under "Register Info" I see my correct e-mail address.
At that e-mail address I receive notifications successfully from some topics (like this) I've subscribe to.
Do I need to do something else? |
|
Posted 22 Sep, 2006 06:34:09
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
|
Posted 22 Sep, 2006 07:26:11
|
|
Top
|
|