Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 592383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:44:03+00:00 2026-05-13T15:44:03+00:00

I’ve written this little MS Outlook 2003 VSTO Add-In using C# and Visual Studio

  • 0

I’ve written this little MS Outlook 2003 VSTO Add-In using C# and Visual Studio 2008. It is meant to check each Mail Item being sent for the word “attach” in the body and if found, then check the number of attachments. If that number is zero, then ask the user if they really mean to send the message. It’s supposed to work like the Gmail labs feature which does the same thing.

The odd thing is that it works, but the first time I run it, I get a pause, like the mail item window is hung for about 45 seconds. Once it gets past that, it runs very fast for the rest of the time I have Outlook open. If I close Outlook though, then the next time I re-open it and send a message, I will have this wait again.

Any ideas, peoples?

Here’s the code for my Add-In:

namespace OutlookAttacher
{
    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            this.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }

        void Application_ItemSend(object Item, ref bool Cancel)
        {
            if (Item is Microsoft.Office.Interop.Outlook.MailItem)
            {
                Microsoft.Office.Interop.Outlook.MailItem currentItem = Item as Microsoft.Office.Interop.Outlook.MailItem;
                Cancel = true;

                if (currentItem.Body.Contains("attach"))
                {
                    if (currentItem.Attachments.Count > 0)
                    {
                        Cancel = false;
                        //MessageBox.Show("This message will be sent now.");
                        currentItem.Send();
                    }
                    else
                    {
                        DialogResult ans = MessageBox.Show("This message has no attachments. Are you sure you want to send it?", "OutlookAttacher", MessageBoxButtons.YesNo);
                        if (ans.Equals(DialogResult.Yes))
                        {
                            Cancel = false;
                            //MessageBox.Show("This message will be sent now.");
                            currentItem.Send();
                        }
                    }
                }
                else
                {
                    Cancel = false;
                    //MessageBox.Show("This message will be sent now.");
                    currentItem.Send();
                }
            }
        }
    }
}

Any suggestions for improving the code are welcome as well, since this is my first stab at an Outlook Add-In.

Update: I am running this on a 5-year Dell laptop, 2 GB of Ram and I-don’t-know-which Intel CPU. I like the idea of adding a trace / debugging it. I will have to go figure out how to step through the code so I can see where it might be taking the longest time. Thanks y’all!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:44:03+00:00Added an answer on May 13, 2026 at 3:44 pm

    OK, I’m really embarrassed. The delay I was seeing was just Outlook synching with my Exchange server. I was at home when I was testing and Outlook was still connecting via HTTP. I am seeing it work fast today, in the office, so no HTTP. Thanks for the replies anyway.

    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.