/// <summary> /// Function Name : ParseNewEmail /// Input Parameters : none /// Input Parameter Type : none /// Description:This method is going to record the event when an email is received to the Test email. It uses ImapClient which is available in AE.Net.Mail Nuget package. /// ImapClient has inbuilt properties to extract subject, body, sender information details from a newly received email /// </summary> /// <returns> /// Return Parameter : emailJson /// Return Parameter Type : string /// </returns> public string ParseNewEmail() { // Connect to the IMAP server. The 'true' parameter specifies to use SSL, which is important (for Gmail at least) ImapClient imapClient = new ImapClient(ConfigurationManager.AppSettings["ImapServer"], ConfigurationManager.AppSettings["UserId"], ConfigurationManager.AppSettings["Password"], AuthMethods.Login, 993, true); var userName = ConfigurationManager.AppSettings["UserID"]; // ImapClient imapClient = new ImapClient(ConfigurationManager.AppSettings["ImapServer"], "*****@*****.**", "7Ywy7N[S", AuthMethods.Login, 993, true); // Select a mailbox. Case-insensitive imapClient.SelectMailbox("INBOX"); string emailJson=""; imapClient.NewMessage += (sender, e) => { var msg = imapClient.GetMessage(e.MessageCount - 1); UpdatePackage up = new UpdatePackage(); up.Updates = ParseBody(msg.Body); up.Subject = msg.Subject; up.Body = msg.Body; up.ProjectName = ApplicationName; emailJson = JsonConvert.SerializeObject(up); string result = ""; using (var client = new WebClient()) { client.Headers[HttpRequestHeader.ContentType] = "application/json"; // result = client.UploadString("https://localhost:44300/ProjectUpdate/Update", "Post", emailJson); result = client.UploadString("https://costcodevops.azurewebsites.net/ProjectUpdate/Update", "Post", emailJson); Console.WriteLine(result); } }; return emailJson; }
/// <summary> /// Function Name : ParseNewEmail /// Input Parameters : none /// Input Parameter Type : none /// Description:This method is going to record the event when an email is received to the Test email. It uses ImapClient which is available in AE.Net.Mail Nuget package. /// ImapClient has inbuilt properties to extract subject, body, sender information details from a newly received email /// </summary> /// <returns> /// Return Parameter : emailJson /// Return Parameter Type : string /// </returns> public string ParseNewEmail() { // Connect to the IMAP server. The 'true' parameter specifies to use SSL, which is important (for Gmail at least) ImapClient imapClient = new ImapClient(ConfigurationManager.AppSettings["ImapServer"], ConfigurationManager.AppSettings["UserId"], ConfigurationManager.AppSettings["Password"], AuthMethods.Login, 993, true); var userName = ConfigurationManager.AppSettings["UserID"]; // ImapClient imapClient = new ImapClient(ConfigurationManager.AppSettings["ImapServer"], "*****@*****.**", "7Ywy7N[S", AuthMethods.Login, 993, true); // Select a mailbox. Case-insensitive imapClient.SelectMailbox("INBOX"); string emailJson = ""; imapClient.NewMessage += (sender, e) => { var msg = imapClient.GetMessage(e.MessageCount - 1); UpdatePackage up = new UpdatePackage(); up.Updates = ParseBody(msg.Body); up.Subject = msg.Subject; up.Body = msg.Body; up.ProjectName = ApplicationName; emailJson = JsonConvert.SerializeObject(up); string result = ""; using (var client = new WebClient()) { client.Headers[HttpRequestHeader.ContentType] = "application/json"; // result = client.UploadString("https://localhost:44300/ProjectUpdate/Update", "Post", emailJson); result = client.UploadString("https://costcodevops.azurewebsites.net/ProjectUpdate/Update", "Post", emailJson); Console.WriteLine(result); } }; return(emailJson); }