gpt4 book ai didi

c# - 将 Redemption (Outlook) 与登录用户以外的用户一起使用 - 并出现错误

转载 作者:行者123 更新时间:2023-11-30 22:50:25 24 4
gpt4 key购买 nike

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

我在 Windows Scheduler 中以我的用户名运行 exe,它工作正常,我收到一封发送给我的电子邮件(见下面的代码)。

当我将 Scheduler 中的 runas 用户名更改为其他人并尝试访问他们的邮箱配置文件时,我收到错误消息。系统.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 =
"\n outLookUser: " + outLookUser +
"\n outLookServer: " + outLookServer +
"\n\n";

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 +=
"\n mailboxCount: " + mailboxCount.ToString() +
"\n defaultStore: " + defaultStore +
"\n\n";


//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 + "\n";
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 时,出现此错误,

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)

有没有人对我做错了什么有任何想法,可以以这种方式使用救赎吗?

最佳答案

我最终通过确保您登录的用户对您尝试查看的邮箱具有“完全邮箱权限”来实现此目的。

关于c# - 将 Redemption (Outlook) 与登录用户以外的用户一起使用 - 并出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/589254/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com