This commit is contained in:
2019-07-04 18:17:34 +00:00
parent f55042fe05
commit 73dee0e8d1
3 changed files with 173 additions and 2 deletions

View File

@@ -200,6 +200,51 @@ namespace rockfishCore.Util
#endregion
#region handle read and move message
/// <summary>
/// Move to sub or unsub mail folder and mark as read
/// </summary>
/// <param name="moveMessageId"></param>
/// <param name="replyFromAccount"></param>
public static void MoveAndMarkRead(uint moveMessageId, rfMailAccount replyFromAccount, bool toSubscribed)
{
using (var client = new ImapClient())
{
// Accept all SSL certificates
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT);
// Note: since we don't have an OAuth2 token, disable
// the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2");
if (replyFromAccount == rfMailAccount.support)
{
client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT);
}
else
{
client.Authenticate(MAIL_ACCOUNT_SALES, MAIL_ACCOUNT_PASSWORD_SALES);
}
//AyaNovaReceivedNOTSUB
//AyaNovaReceivedSubscribed
var newFolder = client.GetFolder(toSubscribed?"AyaNovaReceivedSubscribed":"AyaNovaReceivedNOTSUB");
if (newFolder != null)
{
client.Inbox.Open(FolderAccess.ReadWrite);
client.Inbox.MoveTo(new UniqueId(moveMessageId), newFolder);
}
client.Disconnect(true);
}
}//spaminator
#endregion