private async void receiveButton_Click(object sender, RoutedEventArgs e) { using (HttpClient client = new HttpClient()) { var input = new Dictionary <string, string> { { "email", email }, }; var encodedInput = new HttpFormUrlEncodedContent(input); //try //{ List <string> tmpList; var resp = await client.PostAsync(new Uri("http://evocreate.tk/retrieveMail.php"), encodedInput); if (resp.StatusCode.Equals(HttpStatusCode.NotFound)) { emailView.ItemsSource = new List <string>() { "No email records found." } } ; else if (resp.StatusCode.Equals(HttpStatusCode.Ok)) { allEmails = new List <AbsEmailRecord>(); string respString = resp.Content.ToString(); respString = respString.Replace("<hr/>", "{"); respString = respString.Substring(1, respString.Count() - 1); List <string> emailsList = respString.Split('{').ToList(); foreach (string s in emailsList) { string snew; snew = s.Replace("<br/>", "{"); tmpList = snew.Split("{".ToCharArray()).ToList(); if (tmpList[0] == "noAbsMailUID") { AbsEmailRecord aer = new AbsEmailRecord(tmpList[1], tmpList[2], tmpList[3], tmpList[4], tmpList[5], tmpList[6], false); allEmails.Add(aer); } else { AbsEmailRecord aer = new AbsEmailRecord(tmpList[1], tmpList[2], tmpList[3], tmpList[4], tmpList[5], tmpList[6], true, tmpList[7]); allEmails.Add(aer); } } emailView.ItemsSource = allEmails; } else { DisplayDialog("Error!", "Request timed out!"); } //} //catch (Exception) //{ // DisplayDialog("Error!", "Ensure that you have internet connectivity!"); //} } }
private async void emailView_Tapped(object sender, TappedRoutedEventArgs e) { if (emailView.SelectedItem != null) { AbsEmailRecord aer = (AbsEmailRecord)emailView.SelectedItem; if (aer.IsAbsSecureVerified) { currentEmail = aer; HideUnhideEverything(false); goBackBtn.Visibility = Visibility.Visible; emailTxtBlock.Visibility = Visibility.Visible; integCheckBtn.Visibility = Visibility.Visible; decryptBtn.Visibility = Visibility.Visible; changeContentBtn.Visibility = Visibility.Visible; emailTxtBlock.Text = aer.showFullContent(); emailContent.Text = currentEmail.EmailContent; } else { if (isAbsSecureEnabled) { using (HttpClient client = new HttpClient()) { var input = new Dictionary <string, string> { { "option", "4" }, { "senderEmail", aer.SenderEmail }, }; var encodedInput = new HttpFormUrlEncodedContent(input); try { var resp = await client.PostAsync(new Uri("http://evocreate.tk/checkAffiliation.php"), encodedInput); if (resp.StatusCode.Equals(HttpStatusCode.BadRequest)) { goto showEmail; } else { input["option"] = "5"; encodedInput = new HttpFormUrlEncodedContent(input); resp = await client.PostAsync(new Uri("http://evocreate.tk/checkAffiliation.php"), encodedInput); string supposedSenderCompany = resp.Content.ToString(); //displayBox.Text = supposedSenderCompany; input.Add("senderCompanyID", supposedSenderCompany); input.Add("recipCompanyID", companyID); input["option"] = "2"; encodedInput = new HttpFormUrlEncodedContent(input); var resp2 = await client.PostAsync(new Uri("http://evocreate.tk/checkAffiliation.php"), encodedInput); input["option"] = "3"; encodedInput = new HttpFormUrlEncodedContent(input); var resp3 = await client.PostAsync(new Uri("http://evocreate.tk/checkAffiliation.php"), encodedInput); if (!(resp2.StatusCode.Equals(HttpStatusCode.Accepted)) && !(resp3.StatusCode.Equals(HttpStatusCode.Accepted))) { goto showEmail; } else { DisplayDialog("Alert!", "The sender of this email has spoofed his address to one that is trusted by your corporation, delete this email immediately!"); return; } } } catch (Exception) { DisplayDialog("Error!", "Ensure that you have internet connectivity!"); } } } showEmail: { showEmail(aer.showFullContent()); } } } }