与登录用户以外的用户一起使用 Redemption (Outlook) - 并出现错误 [英] Using Redemption (Outlook) with a user other than the logged in user - and getting errors

查看:21
本文介绍了与登录用户以外的用户一起使用 Redemption (Outlook) - 并出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Redemption dll (http://www.dimastr.com/redemption/) 并且我已经创建了一个可以访问我的邮箱的 exe.

I'm using Redemption dll (http://www.dimastr.com/redemption/) and I've created an exe that accesses my mail box.

我在 Windows Scheduler 中以我的用户名运行 exe 并且运行良好,我收到一封电子邮件(见下面的代码).

I run the exe in Windows Scheduler under my username and it works fine, I get an email sent to me (see below code).

当我将 Scheduler 中的 runas 用户名更改为其他人并尝试访问他们的邮箱配置文件时,出现错误.System.IO.FileLoadException

When I change the runas username in Scheduler to someone else and try to access their mail box Profile I get an error. System.IO.FileLoadException

static void Main(string[] args)
{

    System.Diagnostics.Debugger.Break();

    object oItems;

    //string outLookUser = "My Profile Name";
    string outLookUser = "Other User Profile Name";

    string ToEmailAddress = "abc.email@xyz.com";
    string FromEmailAddress = "abc.email@xyz.com";
    string outLookServer = "exchangeServer.com";

    string sMessageBody =
        "
 outLookUser: " + outLookUser +
        "
 outLookServer: " + outLookServer +
        "

";

    RDOSession Session = null;

    try
    {
        rdoDefaultFolders olFolderInbox = rdoDefaultFolders.olFolderInbox;

        Session = new RDOSession();
        RDOFolder objFolder;

        Session.LogonExchangeMailbox(outLookUser, outLookServer);

        int mailboxCount = Session.Stores.Count;
        string defaultStore = Session.Stores.DefaultStore.Name;

        sMessageBody +=
        "
 mailboxCount: " + mailboxCount.ToString() +
        "
 defaultStore: " + defaultStore +
        "

";


        //RDOStore rmpMetering = Session.Stores.GetSharedMailbox("Name of another mailbox");
        //objFolder = rmpMetering.GetDefaultFolder(olFolderInbox);

        objFolder = Session.GetDefaultFolder(olFolderInbox);

        oItems = objFolder.Items;
        int totalcount = objFolder.Items.Count;
        if (totalcount > 10) totalcount = 10;

        for (int loopcounter = 1; loopcounter < totalcount; loopcounter++)
        {
            RDOMail oItem = objFolder.Items[loopcounter];

            string attachmentName = string.Empty;
            foreach (RDOAttachment attachment in oItem.Attachments)
            {
                attachmentName += attachment.FileName + " ";


                if (attachmentName.Trim() == "Data.csv")
                {
                    attachment.SaveAsFile(@"C:datafiles" + attachmentName.Trim());

                    foreach (RDOFolder archiveFolder in objFolder.Folders)
                    {
                        if (archiveFolder.Name == "DataFileArchive")
                        {
                            oItem.MarkRead(true);
                            oItem.Move(archiveFolder);
                        }
                    }
                }
            }

            sMessageBody += oItem.Subject + " " + attachmentName + "
";
            if ((oItem.UnRead))
            {
                //Do whatever you need this for                    
                //sMessageBody = oItem.Body;
                //oItem.MarkRead(true);
            }
        }

        System.Web.Mail.SmtpMail.Send(ToEmailAddress,FromEmailAddress
            , "Data File Processing-" + DateTime.Now.ToString()
            ,"" + sMessageBody);

    }
    catch (Exception ex)
    {
        Session = null;

        System.Web.Mail.SmtpMail.Send(ToEmailAddress, FromEmailAddress, "Error", sMessageBody + " " + ex.Message);

    }
    finally
    {
        if ((Session != null))
        {
            if (Session.LoggedOn)
            {
                Session.Logoff();
            }
        }
    }

}

当我尝试在另一台已登录的机器上运行相同的 exe 时,出现此错误,

When I try to run the same exe on another machine with me logged in I get this error,

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass
embly 'Interop.Redemption, Version=4.7.0.0, Culture=neutral, PublicKeyToken=null
' or one of its dependencies. The system cannot find the file specified.
File name: 'Interop.Redemption, Version=4.7.0.0, Culture=neutral, PublicKeyToken
=null'
   at RPMDataFileProcessing.Program.Main(String[] args)

有没有人知道我做错了什么,可以这样使用救赎吗?

Has anyone got any ideas on what I'm doing wrong, can Redemption be used in this way?

推荐答案

我最终通过确保您登录的用户对您尝试查看的邮箱拥有完整邮箱权限"来完成这项工作.

I got this working in the end by ensuring that the user you are logged in as, has 'full mailbox rights' to the mail box you are trying to see.

这篇关于与登录用户以外的用户一起使用 Redemption (Outlook) - 并出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆