none
How to get all email from outlook by a specefic email id . RRS feed

  • Question

  • Hi all ,

    I want to get all email of a particular email id .Below is the code where i am getting all emails from Inbox .

    Outlook.NameSpace outlookNameSpace = this.application.GetNamespace("MAPI");
    Outlook.MAPIFolder inbox = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);

    Please help me to get all mails of a particular email id .



    • Edited by Sohan India Monday, December 2, 2013 3:37 AM
    Monday, December 2, 2013 3:36 AM

Answers

All replies

  • What kind of id? If it is an entry id (MailItem.EntryID), call Namespace.GetItemfromID. If it is a MIME Message-ID header value, use MAPIFolder.Items.Find specifying the PR_INTERNET_MESSAGE_ID property (DASL name "http://schemas.microsoft.com/mapi/proptag/0x1035001F")

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

    Monday, December 2, 2013 3:42 AM
  • Dear Dmitry ,

    ID would be emailID , i want to get all those email from inbox which comes from a particular email id , Like my email id is sohan@gmail.com . I want to get all emails from inbox whose sender is sohan@gmail.com .Please help .


    • Edited by Sohan India Monday, December 2, 2013 3:45 AM
    Monday, December 2, 2013 3:45 AM
  • Ok, so you want the sender email address, not id.

    Try

    Items items = inbox.Items;
    MailItem msg = items.Find("[SenderEmailAddress] = 'sohan@gmail.com' ");
    while(msg != null)
    {
      MessageBox.Show(msg.Subject);
      msg = items.FindNext();
    }
    


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

    Monday, December 2, 2013 4:06 AM
  • Dear Dmitry ,

    Thanx for the quick reply , Now i am able to get those mail which comes from gmail server . But still not able to get those mail which comes from exchage mail server like my office mail id is sohan@example.com . I am able to get all mails from sohan@gmail.com id but not able to get all emails from sohan@example.com .

    Please help me its so much urgent

    Monday, December 2, 2013 5:00 AM
  • Hi all ,

    I am not able to implement find method in the case of exchangeUser.

    Pelase helppppppppppppppppp

    Monday, December 2, 2013 5:36 AM
  • Are you sure the sender email address is actually sohan@gmail.com ? Or is it an Exchange type address/

    Take a look at the message with OutlookSpy - click Item button, select the SenderEmailAddress property. What is its value? Or click IMessage button and select the PR_SENDER_EMAIL_ADDRESS property.


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

    Monday, December 2, 2013 5:41 AM
  • Dear Dmitry ,

    I have seen through OutlookSpy and it is showing Exchange type address/ .

    Please help me to achieve my task .

    Monday, December 2, 2013 5:59 AM
  • That means you need to search by the EX address.

    Try to search by the SMTP address first. If that fails, use Namespace.CreateRecipient / Recipient.Resolve. If Recipient.AddressEntry.Type returns "EX", use the Address property to search by it.


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

    Monday, December 2, 2013 6:08 AM
  • Dear Dmitry  ,

    Can you please give me sample code as you sent last time . Please i am very new in office development . Please help .....

    Monday, December 2, 2013 6:10 AM
  • Which method are you having problems with?

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

    Monday, December 2, 2013 6:21 AM
  • How to search with  SMTP address ??
    Monday, December 2, 2013 6:24 AM
  • Did you see my code snippet earlier in the thread?

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

    Monday, December 2, 2013 6:37 AM
  • I have seen your previous code snippet , but dont know exact property string for searching . My code is this :-

     MailItem msg = items.Find("[SMTP address] = 'svam'");


    and SenderEmailAddress property value is 

    /O=SVAM/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=SKumar

    Monday, December 2, 2013 6:45 AM
  • Monday, December 2, 2013 7:12 AM
  • "SMTP address" is not a valid property name.

    In case of an EX address, your query must be

    MailItem msg = items.Find("[SenderEmailAddress] = '/O=SVAM/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=SKumar' ");


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

    Monday, December 2, 2013 7:29 AM
  • Dear Dmitry ,

    I am having simply email id that is sohan.kumar@svam.com in database . How i can convert it :-

    sohan .kumar to   '/O=SVAM/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=SKumar' ")

    Please help

    Monday, December 2, 2013 7:55 AM
  • Please reply .......
    Monday, December 2, 2013 8:30 AM
  • Have you tried my suggestion of using Namespace.CreateRecipient / Recipient.Resolve?

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

    • Marked as answer by Sohan India Tuesday, December 3, 2013 9:27 AM
    Monday, December 2, 2013 1:24 PM
  • Hello Dmitry ,

    Thank you so much , I did it :)

    thank you all

    Tuesday, December 3, 2013 8:22 AM