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
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
" ; - // form["to"] = the_name + " <" + the_email + ">";
- // form["from"] = Convert.ToString(App.Current.Properties["ZeeraCustomerFirstName"]) + " " + Convert.ToString(App.Current.Properties["ZeeraCustomerLastName"]) + " <" + Convert.ToString(App.Current.Properties["ZeeraCustomerEmail"]) + ">";
- form["to"] = txtShareQRCodeName.Text + " <" + txtShareQRCodeEmail.Text + ">";
- form["subject"] = txtShareQRCodeSubject.Text;
- body = "";
- body += "";
- body += "";
- body += "";
- body += "";
- body += "";
- body += "Dear " + txtShareQRCodeName.Text + "
"; - body += Convert.ToString(App.Current.Properties["ZeeraCustomerFirstName"]) + " has sent you the attached Zeera QR code with below details:";
- // body += txtContactZeeraMessage.Text;
- body += "";
- body += "";
- form["html"] = Regex.Replace(body, @"\r\n?|\n", "
"); - 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
Altaf AnsariPosted Dec 20, 2017, 1:46 AM