views:

14

answers:

0

Here is the code that I am using. I have spent some time looking at the Redemption objects, but, nothing jumps out at me:

    public static bool PopEmail(string domainUserName, string mSubject, string mBody, string mTo, string mCc = "", string mBcc = "", List<String> fileAttachments = null)
    {
        log.Info("Starting to Pop Outlook Email Message");
        RDOSession oSession = new RDOSession();
        try
        {
            oSession.LogonExchangeMailbox(domainUserName, string.Empty);
            if (oSession.LoggedOn)
            {
                RDOMail oMail = oSession.GetDefaultFolder(rdoDefaultFolders.olFolderOutbox).Items.Add("IPM.Note");
                oMail.Subject = mSubject;
                oMail.Body = mBody;
                oMail.To = mTo;
                oMail.CC = mCc;
                oMail.BCC = mBcc;
                if (fileAttachments != null)
                {
                    foreach (string file in fileAttachments)
                    {
                        object newFile = file;
                        oMail.Attachments.Add(newFile, Type.Missing, Type.Missing, Type.Missing);
                        newFile = null;
                    }
                }
                oMail.Display();
                Marshal.FinalReleaseComObject(oMail);
                oMail = null;
            }
            oSession.Logoff();
            Marshal.FinalReleaseComObject(oSession);
            oSession = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            log.Info("Outlook Email has been Popped.");
            return true;
        }
        catch (Exception)
        {
            log.Error("Outlook Pop Email Failed.");
            throw;
        }
    }

Thank you,