2

How can i send an email with attachment in windows universal app (windows phone 8.1 and windows 8.1)

Class Windows.ApplicationModel.Email.EmailMessage is available only for windows phone

Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
Nopster
  • 97
  • 7

3 Answers3

3

There is no direct, in-box way to send an email in a Windows Store app.

As you note, Windows.ApplicationModel.Email is available only for Windows Phone Runtime apps. This is one of the discontinuities in Universal apps where a feature is available on one platform but not both.

Options are:

  • Use the share contract rather than explicitly forcing email. This is the preferred method in general, although there are specific cases for which it doesn't work
  • Connect to a web service. This is often the best solution for feedback since the app can provide a custom form and doesn't have to push the user through an external app. You could also use a web service which will forward to email on the server side.
  • Connect to the mail server directly and implement SMTP, POP, IMAP, etc. This is generally best for service specific apps which can expose their own share target.
  • Not relevant for your case, but if you didn't need the attachment you could launch a mailto: URI
Rob Caplan - MSFT
  • 21,714
  • 3
  • 32
  • 54
0

You could use MailMessage email = new MailMessage(); from System.Net.Mail-Namesapce

Greenhorn
  • 74
  • 6
0

You can use SMTP for sending email in windows 8:

SmtpMail oMail = new SmtpMail("TryIt");
oSmtp = new SmtpClient();
oMail.From = new MailAddress("abc@gmail.com");
oMail.To.Add(new MailAddress("xyz@gmail.com"));
oMail.Subject = "Subject ";
oMail.TextBody = "Here is body";
SmtpServer oServer = new SmtpServer("smtp.gmail.com");
oServer.User = "abc@gmail.com";
oServer.Password = "123456";
oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
await oSmtp.SendMailAsync(oServer, oMail);
Max
  • 1,810
  • 3
  • 26
  • 37
Hassaan
  • 35
  • 5