විද්‍යුත් තැපැල් කියවමු

මම දන්නව කට්ටිය ඕනෙ තරම් පාවිච්චි කරල ඇති Microsoft office Outlook 2007 විද්‍යුත් තැපැල් කියවන්න. නමුත් මම කියන්නෙ යන්නෙ outlook 2007 වලින් නිකම්ම කියවන හැටි නොවේ.

මම පාවිච්චි කරන්නෙ C#.net. මම පෙන්නන පහත දැක්වෙන method එකෙන් මේල් කියවනව. කියවල එන MailItem එකට අපිට ඕනෙ දෙයක් කරන්න පුලුවන්.

Outlook DLL පාවිච්චි කරන නිස මේකෙන් mail කියවන්න,යවන්න,contacts හදන්න,calendar item දාන්න වගෙ outlook පාව්ච්චි කරල කරන ඕනෙ දෙයක් කරන්න පුලුවන්. 

 public void ReadUnReadMail()
        {
            string userName = ConfigurationSettings.AppSettings["UserName"].ToString();
            string password = ConfigurationSettings.AppSettings["Password"].ToString();
            Microsoft.Office.Interop.Outlook.MailItem item = null;
            try
            {
                app = new Microsoft.Office.Interop.Outlook.Application();
               
                ns = app.GetNamespace("MAPI");
                ns.Logon(userName, password, false, true);

                inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);

                for (int i = 1; i <= inboxFolder.Items.Count; i++)
                {
                    item = (Microsoft.Office.Interop.Outlook.MailItem)inboxFolder.Items[i];

                    if (item != null)
                    {
                        //do what ever you want
                    } 
                }
            }
            catch (Exception  ex)
            {               
                System.Diagnostics.EventLog myEventLog = new System.Diagnostics.EventLog();
                myEventLog.Log = "Application";
                myEventLog.Source = "what ever";
                myEventLog.WriteEntry(ex.ToString());
            }
            finally
            {
                ns = null;
                app = null;
                inboxFolder = null;
            }
        }
ඇත්තටම මම මෙක ලිව්වෙ හෙනට ඉන්ටනෙට් එකේ හොයල. නමුත් මට මතක නැහැ කොහෙන් කොහෙන් මෙව්ව හොයා ගත්තද කියල.

මොනව උනත් මෙකේ තේරෙන්නෙ නැති හරි වැඩ කරන්නෙ නැති හරි මොකක් හරි සීන් එකක් තියෙනවනම් අහන්න මම කොහොම හරි පුළුවන් විදිහකට උත්තර දෙන්නම්.

0 ප්‍රතිචාර:

Post a Comment