Hi,
I am using below code to send email using Mailgun and HttpClient.
I now have an image on my page which is imgProfile and I want to send this image as an attachment in the same code.
How can Id o that please?
- async Task<HttpStatusCode> SendMessage()
- {
- try
- {
- loadingShareQRCode.IsBusy = true;
-
- var client = new HttpClient();
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes("api" + ":" + "key-xxxxxxxxxxxxx")));
-
- var form = new Dictionary<string, string>();
- form["from"] = "Zeera <[email protected]>";
-
-
- form["to"] = txtShareQRCodeName.Text + " <" + txtShareQRCodeEmail.Text + ">";
- form["subject"] = txtShareQRCodeSubject.Text;
-
- body = "<html dir='ltr' lang='en'>";
- body += "<head>";
- body += "<meta charset='UTF-8'>";
- body += "<meta name='viewport' content='width=device-width, initial-scale=1.0'>";
- body += "</head>";
- body += "<body dir='ltr' lang='en'>";
- body += "Dear " + txtShareQRCodeName.Text + "<br /><br />";
- body += Convert.ToString(App.Current.Properties["ZeeraCustomerFirstName"]) + " has sent you the attached Zeera QR code with below details:";
-
- body += "</body>";
- body += "</html>";
-
- form["html"] = Regex.Replace(body, @"\r\n?|\n", "<br />");
-
- var response = await client.PostAsync("https://api.mailgun.net/v2/" + "reach.softnames.com" + "/messages", new FormUrlEncodedContent(form));
-
- return response.StatusCode;
- }
- catch
- {
- loadingShareQRCode.IsVisible = false;
- loadingShareQRCode.IsBusy = false;
- btnShareQRCodeSend.IsVisible = true;
- }
-
- return HttpStatusCode.Unused;
- }
Thanks,
Jassim