I am able to retrieve all the emails and log them but I can't seem to get the body to just be plain text. I've tried looking at other examples on here but I can't seem to grasp the problem. Below is my code so far:
//retrieve emails in blocks of 50
int offset = 1;
int pageSize = 50;
bool moreEmails = true;
ItemView view = new ItemView(pageSize, offset, OffsetBasePoint.Beginning);
view.PropertySet = PropertySet.IdOnly;
while (moreEmails)
{
findResults = service.FindItems(WellKnownFolderName.Inbox, view);
foreach (var item in findResults.Items)
{
emails.Add((EmailMessage)item);
}
moreEmails = findResults.MoreAvailable;
if (moreEmails)
{
view.Offset += pageSize;
}
}
PropertySet properties = new
PropertySet (BasePropertySet.FirstClassProperties);
service.LoadPropertiesForItems(emails, properties);
properties.RequestedBodyType = BodyType.Text;
I'm initialising the variables in a separate function:
private static void CheckRules()
{
try
{
foreach (var EmailParam in emails)
{
FromEmail = EmailParam.From.Address.ToString();
EmailDate = EmailParam.DateTimeReceived.ToString("yyyy-MM-dd hh:mm:ss");
EmailSubject = EmailParam.Subject.ToString();
EmailBody = EmailParam.Body.Text.ToString();
etc...
So again, I just want the body to be plain text. Thanks in advance for any help!