Outlook from the Managed World

Sign in to queue

The Discussion

  • User profile image
    Eva Li

    Compile error for GetNamespace(...). Any suggestions?

    Thanks!

    Eva

  • User profile image
    Eva Li

    After install the downloaded code, the project can not be loaded to VS 2005.

  • User profile image
    Eva Li

    I installed VSTO 2005. However the Office folder does not show in my VS 2005 under my Visual C#. I tried re-booting my system and uninstall, reinstall. It still does not show. Do you know why?

    Thanks!

  • User profile image
    shailesh joge

    this code should also in c# users

  • User profile image
    ruchi

    how can we receive mails from inbox folder?

  • User profile image
    Balaji

    I am getting a compiler error for

    GetNamespace("MAPI")

    please tell  me what to do

  • User profile image
    Clint

    do you have VSTO and VS Pro?

  • User profile image
    chance

    I got the GetNamespace error when I first tried the code as well.  I had to change it to the following to get it to work:

    Outlook.MAPIFolder outBoxFolder = (Outlook.MAPIFolder)outlookObj.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);

  • User profile image
    Clint

    @Chance:  Thanks

  • User profile image
    ganesha

    how can we search for a particular mail in inbox

  • User profile image
    Darren Brown

    Whats does outlookObj refer to in the code above.

  • User profile image
    Clint

    @Darren Brown:  I see no reference to outlookObj, what line number / code base are you looking at?

  • User profile image
    Hazar

    Hi.

    I use outlook tasks so often, but in the real world I categorize tasks importance as follows:

    1. Urgent and Important

    2. Urgent

    3. Important

    4. Not urgent and not important

    And I want to change this in outlook when creating new tasks: I want to change the default "High, Low and Normal" values for the importance field...

    Can you please help me with that?

  • User profile image
    shmarov

    Does anybody load .msg file by using VSTO? How can i do it?

    tnx

  • User profile image
    Deaddog4201

    [code]

    public void CreateMessage()

           {

               // Create a new mail item.

               Microsoft.Office.Interop.Outlook._Application outlookObj = new Microsoft.Office.Interop.Outlook.Application();

               Microsoft.Office.Interop.Outlook.MAPIFolder outBoxFolder = (Microsoft.Office.Interop.Outlook.MAPIFolder)outlookObj.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);

               Microsoft.Office.Interop.Outlook.MailItem mailItem = (Microsoft.Office.Interop.Outlook.MailItem)outBoxFolder.Items.Add(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

               mailItem.Subject = "Coding4Fun Sample"; //TODO: Change the Subject field of the e-mail item.

               mailItem.Body = "What ever you want in the body" //TODO: Change the body of the e-mail item.

               mailItem.To = "emailaddress@emailaddress"; //TODO: Change the recipient's address.

               mailItem.Display(false); //true to make the window modal. The default value is false.

           }

           public void CreateTask()

           {

               // Create a new task item.

               Microsoft.Office.Interop.Outlook._Application outlookObj = new Microsoft.Office.Interop.Outlook.Application();

               Microsoft.Office.Interop.Outlook.MAPIFolder tasksFolder = (Microsoft.Office.Interop.Outlook.MAPIFolder)outlookObj.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderTasks);

               Microsoft.Office.Interop.Outlook.TaskItem taskItem = (Microsoft.Office.Interop.Outlook.TaskItem)tasksFolder.Items.Add(Microsoft.Office.Interop.Outlook.OlItemType.olTaskItem);

               taskItem.Subject = "Finish Coding4Fun article!";

               taskItem.Owner = "Bob";

               taskItem.PercentComplete = 0;

               taskItem.Status = Microsoft.Office.Interop.Outlook.OlTaskStatus.olTaskInProgress;

               taskItem.Save();

           }

    [/code]

  • User profile image
    Milind

    Can I set mailItem.from of MailItem ?

  • User profile image
    Clint

    @Milind no you cannot looking at the API.  https://msdn.microsoft.com/en-us/library/bb208402.aspx

  • User profile image
    Clint

    @vusman requires Outlook for the APIs to succeed.  VSTO are extentions for developing against Office.  This is pretty old article as well, stuff may have changed in the new versions since then.  https://msdn.microsoft.com/en-us/vsto/default.aspx is the VSTO page for everything.

  • User profile image
    vusman

    can this code work for users that dont have Microsoft Outlook installed on their PCs

Add Your 2 Cents