VSTO Outlook Addin + IMAP account issue

Pablo Glomby 181 Reputation points
2022-02-03T15:18:10.337+00:00

Hi,
I have a weird problem. It seems an incompatibility between OOM and Outllook and IMAP.

Scenario: I have my default Office 365 account + 1 IMAP account.
I created a very simple addin that just attaches 4 files (6 MB each one) when a new MailItem is created:

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Xml.Linq;  
using Outlook = Microsoft.Office.Interop.Outlook;  
using Office = Microsoft.Office.Core;  
using System.Windows.Forms;  
  
  
namespace TestAddin  
{  
    public partial class ThisAddIn  
    {  
        private void ThisAddIn_Startup(object sender, System.EventArgs e)  
        {  
            Application.Inspectors.NewInspector += Inspectors_NewInspector;  
        }  
  
        private void Inspectors_NewInspector(Outlook.Inspector Inspector)  
        {  
            try  
            {  
                if( Inspector.CurrentItem is Outlook.MailItem )  
                {  
                    Outlook.MailItem mail = Inspector.CurrentItem as Outlook.MailItem;  
                    MessageBox.Show("Before attaching file 1");  
                    mail.Attachments.Add("c:\\temp\\6MB.xlsx");  
                    MessageBox.Show("Before attaching file 2");  
                    mail.Attachments.Add("c:\\temp\\6MB.xlsx");  
                    MessageBox.Show("Before attaching file 3");  
                    mail.Attachments.Add("c:\\temp\\6MB.xlsx");  
                    MessageBox.Show("Before attaching file 4");  
                    mail.Attachments.Add("c:\\temp\\6MB.xlsx");  
                }  
            } catch( Exception ex )  
            {  
                MessageBox.Show("Error in NewInspector: " + ex.ToString());  
            }  
        }  
  
        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)  
        {  
        }  
  
        #region VSTO generated code  
  
        /// <summary>  
        /// Required method for Designer support - do not modify  
        /// the contents of this method with the code editor.  
        /// </summary>  
        private void InternalStartup()  
        {  
            this.Startup += new System.EventHandler(ThisAddIn_Startup);  
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);  
        }  
          
        #endregion  
    }  
}  
  

The problem is that if I start Outlook and I immediately compose an email from my IMAP account then I get:
171026-image.png

And this is just when attaching the fourth attachment... like if there is a 20 MB email limit.
The worst, is that if then I compose an email using my Office 365 account then I get the same error... but in my Office 365 the attachment limit is 35 MB.

Even more, if I don't use this addin I can add this 6 MB attachments as many times as I want...
Even more, if I install this addin and I use my Office 365 account first then this issue does not happen for that Outlook session.
Even more, I can (without this addin) compose an email of 24 MB and send it and it will not be rejected so I don't know from where OOM takes the limit.

It seems that OOM is retrieving a message limit (that is not a valid limit).

Thanks

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,458 questions
{count} votes