2013-09-04 2 views
5

के माध्यम से Outlook ईमेल पता प्राप्त करें मुझे वर्तमान में C# कोड के साथ उपयोगकर्ता के ईमेल पते में लॉग इन करने में सक्षम होना चाहिए।सी #

मुझे पूरा पता होना चाहिए, न केवल अनुमानित ईमेल खाता (जैसे [email protected]), हालांकि यह अधिकांश ग्राहकों के लिए काम करेगा।

किसी भी मदद की सराहना की जाएगी।

+0

मुझे डर है कि मैं इस समय केवल संदर्भ मैं मिल सकता है vb था पर एक प्रयास की जरूरत नहीं है कर रहा हूँ और सही दिशा –

+0

लगभग सभी वीबी में एक बिंदु की जरूरत है संरचनाओं को सी # में आसानी से परिवर्तित किया जा सकता है - एसओ के चारों ओर एक नज़र डालें, जैसे http://stackoverflow.com/questions/4761521/get-the-email-address-of-the-current-user-in-outlook- 2007 आपके लिए आवेदन कर सकता है – jdphenix

उत्तर

5

http://msdn.microsoft.com/en-us/library/ff462091.aspx से इस प्रयास करें,:

using System; 
using System.Text; 
using Outlook = Microsoft.Office.Interop.Outlook; 

namespace OutlookAddIn1 
{ 
    class Sample 
    { 
     public static void DisplayAccountInformation(Outlook.Application application) 
     { 

      // The Namespace Object (Session) has a collection of accounts. 
      Outlook.Accounts accounts = application.Session.Accounts; 

      // Concatenate a message with information about all accounts. 
      StringBuilder builder = new StringBuilder(); 

      // Loop over all accounts and print detail account information. 
      // All properties of the Account object are read-only. 
      foreach (Outlook.Account account in accounts) 
      { 

       // The DisplayName property represents the friendly name of the account. 
       builder.AppendFormat("DisplayName: {0}\n", account.DisplayName); 

       // The UserName property provides an account-based context to determine identity. 
       builder.AppendFormat("UserName: {0}\n", account.UserName); 

       // The SmtpAddress property provides the SMTP address for the account. 
       builder.AppendFormat("SmtpAddress: {0}\n", account.SmtpAddress); 

       // The AccountType property indicates the type of the account. 
       builder.Append("AccountType: "); 
       switch (account.AccountType) 
       { 

        case Outlook.OlAccountType.olExchange: 
         builder.AppendLine("Exchange"); 
         break; 

        case Outlook.OlAccountType.olHttp: 
         builder.AppendLine("Http"); 
         break; 

        case Outlook.OlAccountType.olImap: 
         builder.AppendLine("Imap"); 
         break; 

        case Outlook.OlAccountType.olOtherAccount: 
         builder.AppendLine("Other"); 
         break; 

        case Outlook.OlAccountType.olPop3: 
         builder.AppendLine("Pop3"); 
         break; 
       } 

       builder.AppendLine(); 
      } 

      // Display the account information. 
      System.Windows.Forms.MessageBox.Show(builder.ToString()); 
     } 
    } 
} 
+1

अद्भुत धन्यवाद मैं सही लिपि का उपयोग कर रहा था और इस संदर्भ ने सही संदर्भों को शामिल करने के बहुत आसान मुद्दे में मदद नहीं की है कि एक =) –