[英]How to connect to Office 365 mailbox using redemption
I want to connect to office 365 using redemption and download all the emails from the inbox and from other folders, my development machine is 我想使用赎回连接到Office 365,并从收件箱和其他文件夹下载所有电子邮件,我的开发机器是
regsvr32.exe <fullpath>\\redemption.dll
使用此命令在我的form1.cs文件regsvr32.exe <fullpath>\\redemption.dll
This is the code I am trying to connect to Office365 mailbox 这是我尝试连接到Office365邮箱的代码
string codeBase = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
path = Path.GetDirectoryName(path);
RedemptionLoader.DllLocation32Bit = string.Concat(path, @"\Redemption.dll");
RedemptionLoader.DllLocation64Bit = string.Concat(path, @"\Redemption64.dll");
RDOSession session = RedemptionLoader.new_RDOSession();
session.LogonHostedExchangeMailbox("smtp.office365.com", "abc@domain.com","xxxx");// getting error at this line
if (session.LoggedOn)
{
RDOFolder contactsFolder;
contactsFolder = session.GetDefaultFolder(rdoDefaultFolders.olFolderContacts);
var i = contactsFolder.Folders.Count;
foreach (var item in contactsFolder.Folders)
{
var obj = (RDOFolder2)item;
var name = obj.AddressBookName;
}
}
This is the error I am receiving 这是我收到的错误
System.Runtime.InteropServices.COMException was unhandled 未处理System.Runtime.InteropServices.COMException
ErrorCode=-2147023541 HResult=-2147023541 Message=The specified domain either does not exist or could not be contacted ErrorCode = -2147023541 HResult = -2147023541消息=指定的域不存在或无法联系
Source=Redemption.RDOSession StackTrace: at Redemption.IRDOSession.LogonHostedExchangeMailbox(String SMTPAddress, String UserName, String Password) at Office365Backup.Form1.CreateSession() in D:\\Data\\Projects\\DotNet\\Office365Backup\\Source\\Office365Backup\\Form1.cs:line 40 at Office365Backup.Form1..ctor() in D:\\Data\\Projects\\DotNet\\Office365Backup\\Source\\Office365Backup\\Form1.cs:line 19 at Office365Backup.Program.Main() in D:\\Data\\Projects\\DotNet\\Office365Backup\\Source\\Office365Backup\\Program.cs:line 25 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionC Source = Redemption.RDOSession StackTrace:位于Redemption.IRDOSession.LogonHostedExchangeMailbox(字符串SMTPAddress,字符串用户名,字符串密码)在D:\\ Data \\ Projects \\ DotNet \\ Office365Backup \\ Source \\ Office365Backup \\ Form1.cs中的Office365Backup.Form1.CreateSession()处:D:\\ Data \\ Projects \\ DotNet \\ Office365Backup \\ Source \\ Office365Backup \\ Form1.cs中Office365Backup.Form1..ctor()的第40行:D:\\ Data \\ Projects \\中Office365Backup.Program.Main()的第19行DotNet \\ Office365Backup \\ Source \\ Office365Backup \\ Program.cs:System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,String [] args)位于System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)在Microsoft。 System.Threading.ThreadHelper.ThreadStart_Context(对象状态)处的VisualStudio.HostingProcess.HostProc.RunUsersAssembly()在System.Threading.ExecutionContext.RunInternal(ExecutionContext执行上下文,ContextCallback回调,对象状态,布尔状态在System.Threading.ExecutionC处) ontext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.Threading.ExecutionContext.Run(System.Threading.ThreadHelper.ThreadStart()上的ontext.Run(ExecutionContextexecutionContext,ContextCallback回调,对象状态,布尔值saveSyncCtx)InnerException:
Any advice to successfully acomplish this task. 成功完成此任务的任何建议。
Thanks 谢谢
To connect to an Office 365 mailbox (or any mailbox on Exchange 2013 or 2016), you will need the Outlook version of MAPI (Outlook 2010 SP2, Outlook 2013 SP1, or Outlook 2016) - the standalone version of MAPI cannot connect as Exchange will refuse the connection. 若要连接到Office 365邮箱(或Exchange 2013或2016上的任何邮箱),您将需要Outlook版本的MAPI(Outlook 2010 SP2,Outlook 2013 SP1或Outlook 2016)-MAPI的独立版本无法连接,因为Exchange拒绝连接。
Also note that the first argument in LogonHostedExchangeMailbox
is the SMTP address of the user, not a server name. 还请注意, LogonHostedExchangeMailbox
中的第一个参数是用户的SMTP地址,而不是服务器名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.