in Office365APIEditor/UI/FolderViewerForm.cs [338:413]
private void ShowMessages(List<ViewerHelper.Data.MailAPI.Message> messages)
{
// Show all messages in List.
try
{
foreach (var item in messages)
{
// Add new row.
string rowReceivedDateTime = item.ReceivedDateTime ?? "";
string rowCreatedDateTime = item.CreatedDateTime ?? "";
string rowSentDateTime = item.SentDateTime ?? "";
string subject = item.Subject ?? "";
string sender = (item.Sender != null && item.Sender.EmailAddress != null && item.Sender.EmailAddress.Address != null) ? item.Sender.EmailAddress.Address : "";
string recipients = (item.ToRecipients != null) ? ConvertRecipientsListToString(item.ToRecipients) : "";
string isDraft = (item.IsDraft != null && item.IsDraft.HasValue) ? item.IsDraft.Value.ToString() : "";
if (DateTime.TryParse(rowReceivedDateTime, out DateTime receivedDateTime) == false)
{
receivedDateTime = DateTime.MinValue;
}
if (DateTime.TryParse(rowCreatedDateTime, out DateTime createdDateTime) == false)
{
createdDateTime = DateTime.MinValue;
}
if (DateTime.TryParse(rowSentDateTime, out DateTime sentDateTime) == false)
{
sentDateTime = DateTime.MinValue;
}
DataGridViewRow itemRow = new DataGridViewRow
{
Tag = item.Id
};
itemRow.CreateCells(dataGridView_ItemList, new object[] { subject, sender, recipients, receivedDateTime, createdDateTime, sentDateTime });
if (item.IsDraft != null && item.IsDraft.HasValue && item.IsDraft.Value == true)
{
// This item is draft.
itemRow.ContextMenuStrip = contextMenuStrip_ItemList_DraftItem;
}
else
{
// This item is not draft.
itemRow.ContextMenuStrip = contextMenuStrip_ItemList;
}
if (dataGridView_ItemList.InvokeRequired)
{
dataGridView_ItemList.Invoke(new MethodInvoker(delegate { dataGridView_ItemList.Rows.Add(itemRow); }));
}
else
{
dataGridView_ItemList.Rows.Add(itemRow);
}
}
}
catch (InvalidOperationException ex)
{
if (isFormClosing)
{
// It seems that this window was closed.
// Do nothing.
}
else
{
MessageBox.Show(ex.Message, "Office365APIEditor");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.GetType().FullName + "\r\n" + ex.Message, "Office365APIEditor");
}
}