none
regarding the Add-In of Outlook for intercepting the incoming and outgoing mail performance RRS feed

  • Question

  • Hi there,

    I have question is about the Performance Issue of Outlook Add-In. The purpose of Add-In is to intercept incoming and outgoing mail address, subject and save the mail content with attachments as a .msg file. I have provided the source code (.cs) for everyone to refer to : https://1drv.ms/u/s!Aj2Mcyp8XWC1g8oaTFnJvBAY9AP9bA?e=1AYBjq.

    My Process:

      • User preform their outlook
      • When the Mail is incoming or outgoing, the Add-In will be triggered and catch all information of mail
      • To Intercept the mail then Call SharePoint Webservice and pass parameters to web service via URL
      • SharePoint Get the parameters (the type of parameters is Binary, and string)
      • SharePoint Upload the Documents into the Document Library
      • Send the URL of Document (.msg) to D365

    Our problem:

    1. some of the laptop or desktop was installed the Add-In --> the performance will be pretty slowly (Stuck, Freeze) when the user receive or send mail
       
    2. most of time my logs will show us the timeout or cannot connect. Before the Add-In intercepted the mail, it need to check the WebService Status, so I have a function for that. The function name and source code is like the following:
           if (CheckHTTPStatus() == true)
                {
                    Logging.WriteInformation("Inbound_ItemAdded - CheckHTTPStatus() -> true");
                    if (Item is Outlook.MailItem)
                    {
                        // New mail item in inbox folder
                        //MessageBox.Show("you got mail");

                        HandlingMailItem(Item, "Inbound_ItemAdded");
                    }
                }
                else Logging.WriteInformation("Inbound_ItemAdded - CheckHTTPStatus() -> false");

    from my point of view, for the performace issue, I think the issue might be the network issue. Because my code will check the status of WebService everytime, when the Add-In need to Intercept the mail. BUT it cannot connect it . Whether or not someone has any idea on it?  

    My log is the following:

    ******************************************************************************************

    [9:27] [INFO ] [2019-10-11 09-27-47] Event Trigger on 11/10/19
    [9:27] [INFO ] Checking SharePoint Web Service Status ...
    [9:28] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> true
    [9:28] [INFO ] Event -> Inbound_ItemAdded
    [9:28] [INFO ] mailSubject -> NEW ORDER 10-10-19 # 25344
    [9:28] [INFO ] msgFilePath -> C:\TecturaOutlookLogs\NEW ORDER 10-10-19 # 25344.msg
    [9:28] [INFO ] mailItem.SaveAs -> true
    [9:28] [INFO ] mailItem.SaveAs -> Convert to byte[] -> 261632
    [9:28] [INFO ] Waiting CallTecturaWebService - Start -> 11/10/19 9:28:13
    [9:28] [INFO ] outlookAddInWs.Url -> http://******/_layouts/15/TecturaWsListItems/actions.asmx
    [9:28] [INFO ] Tectura_Authentication_Domain -> ******
    [9:28] [INFO ] Tectura_Authentication_UserName -> ******
    [9:28] [INFO ] Tectura_Authentication_Password -> ******
    [9:28] [INFO ] outlookAddInWs.DoUpload -> msgContent -> 261632
    [9:28] [INFO ] outlookAddInWs.DoUpload -> Domain -> ******
    [9:28] [INFO ] outlookAddInWs.DoUpload -> mailFrom -> ******
    [9:28] [INFO ] outlookAddInWs.DoUpload -> FileName -> NEW ORDER 10-10-19 # 25344.msg
    [9:28] [INFO ] outlookAddInWs.Incoming -> true
    [9:28] [INFO ] Waiting CallTecturaWebService - End -> 11/10/19 9:28:14
    [9:28] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> true
    [9:28] [INFO ] Event -> Inbound_ItemAdded
    [9:28] [INFO ] mailSubject -> NEW ORDER # 25369;25343;25350;25347
    [9:28] [INFO ] msgFilePath -> C:\TecturaOutlookLogs\NEW ORDER # 25369;25343;25350;25347.msg
    [9:28] [INFO ] mailItem.SaveAs -> true
    [9:28] [INFO ] mailItem.SaveAs -> Convert to byte[] -> 972288
    [9:28] [INFO ] Waiting CallTecturaWebService - Start -> 11/10/19 9:28:14
    [9:28] [INFO ] outlookAddInWs.Url -> http://******/_layouts/15/TecturaWsListItems/actions.asmx
    [9:28] [INFO ] Tectura_Authentication_Domain -> ******
    [9:28] [INFO ] Tectura_Authentication_UserName -> ******
    [9:28] [INFO ] Tectura_Authentication_Password -> ******
    [9:29] [ERROR] The operation has timed out
    [9:29] [INFO ] Waiting CallTecturaWebService - End -> 11/10/19 9:29:54
    [9:31] [INFO ] The operation has timed out
    [9:31] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:33] [INFO ] The operation has timed out
    [9:33] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:34] [INFO ] The operation has timed out
    [9:34] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:36] [INFO ] The operation has timed out
    [9:36] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:38] [INFO ] The operation has timed out
    [9:38] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:39] [INFO ] The operation has timed out
    [9:39] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:41] [INFO ] The operation has timed out
    [9:41] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:43] [INFO ] The operation has timed out
    [9:43] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:44] [INFO ] The operation has timed out
    [9:44] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:46] [INFO ] The operation has timed out
    [9:46] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:48] [INFO ] The operation has timed out
    [9:48] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [9:52] [INFO ] The operation has timed out
    [9:52] [INFO ] Outbound_ItemSend - CheckHTTPStatus() -> false
    [10:38] [INFO ] Outbound_ItemSend - CheckHTTPStatus() -> true
    [10:38] [INFO ] Event -> Outbound_ItemSend
    [10:38] [INFO ] mailSubject -> Book1.xlsx
    [10:38] [INFO ] msgFilePath -> C:\TecturaOutlookLogs\Book1.xlsx.msg
    [10:38] [INFO ] mailItem.SaveAs -> true
    [10:38] [INFO ] mailItem.SaveAs -> Convert to byte[] -> 68096
    [10:38] [INFO ] Waiting CallTecturaWebService - Start -> 11/10/19 10:38:15
    [10:38] [INFO ] outlookAddInWs.Url -> http://******/_layouts/15/TecturaWsListItems/actions.asmx
    [10:38] [INFO ] Tectura_Authentication_Domain -> ******
    [10:38] [INFO ] Tectura_Authentication_UserName -> ******
    [10:38] [INFO ] Tectura_Authentication_Password -> ******
    [10:38] [INFO ] outlookAddInWs.DoUpload -> msgContent -> 68096
    [10:38] [INFO ] outlookAddInWs.DoUpload -> Domain -> ******
    [10:38] [INFO ] outlookAddInWs.DoUpload -> mailFrom -> ******
    [10:38] [INFO ] outlookAddInWs.DoUpload -> FileName -> Book1.xlsx.msg
    [10:38] [INFO ] outlookAddInWs.Incoming -> false
    [10:38] [INFO ] Waiting CallTecturaWebService - End -> 11/10/19 10:38:36
    [10:41] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> true
    [10:47] [INFO ] [2019-10-11 10-47-14] Event Trigger on 11/10/19
    [10:47] [INFO ] Checking SharePoint Web Service Status ...
    [10:47] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> true
    [10:47] [INFO ] Event -> Inbound_ItemAdded
    [10:47] [INFO ] mailSubject -> RE: NEW ORDER 9-3-19 # 24332
    [10:47] [INFO ] msgFilePath -> C:\TecturaOutlookLogs\RE_ NEW ORDER 9-3-19 # 24332.msg
    [10:47] [INFO ] mailItem.SaveAs -> true
    [10:47] [INFO ] mailItem.SaveAs -> Convert to byte[] -> 103936
    [10:47] [INFO ] Waiting CallTecturaWebService - Start -> 11/10/19 10:47:26
    [10:47] [INFO ] outlookAddInWs.Url -> http://******/_layouts/15/TecturaWsListItems/actions.asmx
    [10:47] [INFO ] Tectura_Authentication_Domain -> ******
    [10:47] [INFO ] Tectura_Authentication_UserName -> ******
    [10:47] [INFO ] Tectura_Authentication_Password -> ******
    [10:47] [INFO ] outlookAddInWs.DoUpload -> msgContent -> 103936
    [10:47] [INFO ] outlookAddInWs.DoUpload -> Domain -> ******
    [10:47] [INFO ] outlookAddInWs.DoUpload -> mailFrom -> ******
    [10:47] [INFO ] outlookAddInWs.DoUpload -> FileName -> RE_ NEW ORDER 9-3-19 # 24332.msg
    [10:47] [INFO ] outlookAddInWs.Incoming -> true
    [10:47] [INFO ] Waiting CallTecturaWebService - End -> 11/10/19 10:47:26
    [10:54] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> true
    [10:54] [INFO ] Event -> Inbound_ItemAdded
    [10:54] [INFO ] mailSubject -> RE: Price quote: RL8197-0.50-Q2 PO#24657
    [10:54] [INFO ] msgFilePath -> C:\TecturaOutlookLogs\RE_ Price quote_ RL8197-0.50-Q2 PO#24657.msg
    [10:54] [INFO ] mailItem.SaveAs -> true
    [10:54] [INFO ] mailItem.SaveAs -> Convert to byte[] -> 747520
    [10:54] [INFO ] Waiting CallTecturaWebService - Start -> 11/10/19 10:54:50
    [10:54] [INFO ] outlookAddInWs.Url -> http://******/_layouts/15/TecturaWsListItems/actions.asmx
    [10:54] [INFO ] Tectura_Authentication_Domain -> ******
    [10:54] [INFO ] Tectura_Authentication_UserName -> ******
    [10:54] [INFO ] Tectura_Authentication_Password -> ******
    [10:56] [ERROR] The operation has timed out
    [10:56] [INFO ] Waiting CallTecturaWebService - End -> 11/10/19 10:56:30
    [11:19] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> true
    [11:19] [INFO ] Event -> Inbound_ItemAdded
    [11:19] [INFO ] mailSubject -> RE: NEW ORDER 9-9-19 # 24562 (PO#24360 and PO#24357)
    [11:19] [INFO ] msgFilePath -> C:\TecturaOutlookLogs\RE_ NEW ORDER 9-9-19 # 24562 (PO#24360 and PO#24357).msg
    [11:19] [INFO ] mailItem.SaveAs -> true
    [11:19] [INFO ] mailItem.SaveAs -> Convert to byte[] -> 123392
    [11:19] [INFO ] Waiting CallTecturaWebService - Start -> 11/10/19 11:19:33
    [11:19] [INFO ] outlookAddInWs.Url -> http://******/_layouts/15/TecturaWsListItems/actions.asmx
    [11:19] [INFO ] Tectura_Authentication_Domain -> ******
    [11:19] [INFO ] Tectura_Authentication_UserName -> ******
    [11:19] [INFO ] Tectura_Authentication_Password -> ******
    [11:19] [INFO ] outlookAddInWs.DoUpload -> msgContent -> 123392
    [11:19] [INFO ] outlookAddInWs.DoUpload -> Domain -> ******
    [11:19] [INFO ] outlookAddInWs.DoUpload -> mailFrom -> ******
    [11:19] [INFO ] outlookAddInWs.DoUpload -> FileName -> RE_ NEW ORDER 9-9-19 # 24562 (PO#24360 and PO#24357).msg
    [11:19] [INFO ] outlookAddInWs.Incoming -> true
    [11:19] [INFO ] Waiting CallTecturaWebService - End -> 11/10/19 11:19:33
    [11:45] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> true
    [11:45] [INFO ] Event -> Inbound_ItemAdded
    [11:45] [INFO ] mailSubject -> RE:  PD LIST--UPDATE
    [11:45] [INFO ] msgFilePath -> C:\TecturaOutlookLogs\RE_  PD LIST--UPDATE.msg
    [11:45] [INFO ] mailItem.SaveAs -> true
    [11:45] [INFO ] mailItem.SaveAs -> Convert to byte[] -> 20043264
    [11:45] [INFO ] Waiting CallTecturaWebService - Start -> 11/10/19 11:45:05
    [11:45] [INFO ] outlookAddInWs.Url -> http://******/_layouts/15/TecturaWsListItems/actions.asmx
    [11:45] [INFO ] Tectura_Authentication_Domain -> ******
    [11:45] [INFO ] Tectura_Authentication_UserName -> ******
    [11:45] [INFO ] Tectura_Authentication_Password -> ******
    [11:45] [ERROR] Index was outside the bounds of the array.
    [11:45] [INFO ] Waiting CallTecturaWebService - End -> 11/10/19 11:45:05
    [11:49] [INFO ] The operation has timed out
    [11:49] [INFO ] Inbound_ItemAdded - CheckHTTPStatus() -> false
    [12:41] [INFO ] The operation has timed out
    [12:41] [INFO ] Outbound_ItemSend - CheckHTTPStatus() -> false

    ******************************************************************************************


    Hi there, if you found my comment very helpful then please | Propose as answer | . Thanks and Regards.


    • Edited by Will .H Monday, October 14, 2019 6:16 AM
    Monday, October 14, 2019 3:30 AM

All replies

  • As a general note, doing any network related work on the main thread is a terrible idea. You really need to offload all network related code to a secondary thread. Keep in ind however that OOM cannot be accessed from a secondary thread from inside a COM addin. You need to retrieve all Outlook related data on the main thread and then start a secondary thread that will perform network calls. If you still need to access Outlook data on the secoindary thread, your only options are Extended MAPI (C++ or Delphi) or Redemption (any language - it wraps Extended MAPI).

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, October 14, 2019 10:50 AM