ConnectTo SentItem for multiple Accounts in Outlook

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

ConnectTo SentItem for multiple Accounts in Outlook
Capturing the Sent Item within Outlook for multiple EMail Accounts 
AdamK




Posts: 25
Joined: 2014-03-09
Following is some base code I am using

    Dim SentItemsEvents As OutlookSentItemsEventsClass = Nothing


Private Sub AddinModule_AddinStartupComplete(sender As Object, e As EventArgs) Handles Me.AddinStartupComplete
        Application.EnableVisualStyles()
        If Debugger.IsAttached Then
            ' Since there is a debugger attached, assume we are running from the IDE
        Else

        End If

        SentItemsEvents = New OutlookSentItemsEventsClass(Me)
        SentItemsEvents.ConnectTo(ADXOlDefaultFolders.olFolderSentMail, True)

    End Sub


Private Sub AddinModule_AddinBeginShutdown(sender As Object, e As EventArgs) Handles Me.AddinBeginShutdown
        If SentItemsEvents IsNot Nothing Then
            If SentItemsEvents.IsConnected Then SentItemsEvents.RemoveConnection()
            SentItemsEvents.Dispose()
        End If

    End Sub



Public Class OutlookSentItemsEventsClass
    Inherits AddinExpress.MSO.ADXOutlookItemsEvents

    Public Sub New(ByVal ADXModule As AddinExpress.MSO.ADXAddinModule)
        MyBase.New(ADXModule)
    End Sub


    Public Overrides Sub ItemAdd(ByVal Item As Object, ByVal SourceFolder As Object)
        Dim boolSaveToDMS As Boolean = False

        If TypeOf (Item) Is Outlook.MailItem Then
            Dim oMsg As Outlook.MailItem = DirectCast(Item, Outlook.MailItem)
            If oMsg IsNot Nothing Then

            End If
            If Not IsNothing(oMsg) Then Marshal.ReleaseComObject(oMsg)
        End If
    End Sub

End Class




If I have an Outlook with multiple accounts how do i define capturing all Sent Items within that Outlook
Or
If i have a terminal server with the AddIn machine based install how do I get the outlook to capture from everyone's sent

Currently it will only capture from the default, which would make sense based on the ConnectTo parameter
But this also happens if every person on the Terminal Server has a single Outlook EMail account, only one person does it save for



How do I get it to ConnectTo / Capture All sent Items from all accounts?
Posted 02 Oct, 2019 01:13:15 Top
Andrei Smolin


Add-in Express team


Posts: 17132
Joined: 2006-05-11
Hello Adam,

You should have an OutlookSentItemsEventsClass per each Sent Items folder in the profile. In Outlook 2007+, you use Namespace.Stores and Store.GetDefaultFolder(...) to get the Sent Items folder on the store. Note that that folder may be missing on some stores!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 02 Oct, 2019 01:36:48 Top
AdamK




Posts: 25
Joined: 2014-03-09
Will this cause interaction concerns between different users on different accounts within a terminal server if all the AddIns across all the opened Outlooks have an OutlookSentItemsEventsClass for each sent items folder of every user currently logged into a terminal server?
so if 4 users have outlook open and a single profile each, and they all create a class for each user then wouldn't this be 16 classes rather than just the 4, one for each user?

For the multiple Outlook accounts within a single Outlook Profile, I would have to create a class for each using the stores and maybe using an array of events classes so these can created dynamically based on if the profile has multiple accounts?
Posted 08 Oct, 2019 01:04:04 Top
Andrei Smolin


Add-in Express team


Posts: 17132
Joined: 2006-05-11
Hello Adam,

This is a normal situation.

If a user has M accounts, you'll have M class instances that handle events. If there's N users running Outlook (on the same machine or on different machines), you have N add-in instances loaded in separate address space.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 08 Oct, 2019 02:05:09 Top