Я получите ошибку:
System.IO.FileNotFoundException: «Не удалось загрузить файл или сборку 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=» 71e9bce111e9429c'. Не могу найти файл.
Код:
Код: Выделить всё
using System;
using Microsoft.Office.Interop.Outlook;
namespace OutlookMailChecker
{
class Program
{
static void Main(string[] args)
{
// Example call to the function with a start date
DateTime fromDate = new DateTime(2023, 1, 1);
CheckEmailForText("string", "string", "[email protected]", "yes", "no", fromDate);
}
static void CheckEmailForText(string subjectText, string bodyText, string mailboxName, string found, string notfound, DateTime fromDate)
{
Application outlookApp = new Application();
NameSpace outlookNamespace = outlookApp.GetNamespace("MAPI");
// Use GetSharedDefaultFolder to access the group mailbox
Recipient recipient = outlookNamespace.CreateRecipient(mailboxName);
if (recipient.Resolve())
{
MAPIFolder inboxFolder = outlookNamespace.GetSharedDefaultFolder(recipient, OlDefaultFolders.olFolderInbox);
Items mailItems = inboxFolder.Items;
}
}
}
}
В моей папке с Outlook:
Код: Выделить всё
C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Outlook\15.0.0.0__71e9bce111e9429c
Подходит ли эта библиотека для такого рода задач? Если да, то как мне правильно прикрепить его к проекту?
Подробнее здесь: https://stackoverflow.com/questions/785 ... ther-via-m