C #, aby przenieść pocztę do PST
Chcę użyć C #, aby uzyskać dostęp do folderu Wysłane programu Outlook i przenieść tam wiadomości do folderu w moim PST o nazwie Archiwum. To jest kod, z którym pracowałem, ale otrzymuję wiele błędów kompilacji. Czy ktoś tutaj z większym doświadczeniem w kodowaniu wie, jak to osiągnąć?
static void MoveMe()
{
try
{
_app = new Microsoft.Office.Interop.Outlook.Application();
_ns = _app.GetNamespace("MAPI");
_ns.Logon(null, null, false, false);
Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);
Outlook.Items SentMailItems = SentMail.Items;
Outlook.MailItem newEmail = null;
foreach (object collectionItem in SentMailItems)
{
moveMail.Move(Archive);
}
}
catch (System.Runtime.InteropServices.COMException ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
_ns = null;
_app = null;
_inboxFolder = null;
}
}
Lista błędów z komentarzy:
Only assignment, call, increment, decrement, and new object expressions can be used as a statement
The type or namespace name 'Emails' could not be found (are you missing a using directive or an assembly reference?)
The name 'A_Sent' does not exist in the current context
The name 'moveMail' does not exist in the current context
The name 'SentMail' does not exist in the current context