In a Windows Phone 7 app, sending an email requires an instance of EmailComposeTask. EmailComposeTask is really easy to use and self-explanatory:
In Windows 8 Metro app, there’s no EmailComposeTask. Instead, you create a “mailto” –uri and launch it:
But when compared to an EmailComposeTask, this only fills the “To” –part, but what about the “Subject” and “Body”? Well, the mailto-syntax allows you to define these as query parameters. For example, here’s an example of defining the “subject”, “body” and “to” –fields from code. The uri is automatically escaped by the platform:
var mailto = new Uri("mailto:?to=recipient@example.com&subject=The subject of an email&body=Hello from a Windows 8 Metro app.");
await Windows.System.Launcher.LaunchUriAsync(mailto);
Read full article here
I have Tried This Code but i have to click on Send Button At Last .is There any way by which i can send it directly without clicking in the send button in the application.
ReplyDeleteThnx
Vimal Bhavsar
Hi Vimal,
ReplyDeleteIn WinRT framework due to security reason and to stop spamming of emails, it has been restricted to send emails from code behind.
Thanx Farhan ,
DeleteSo is there no any way to send email automatically in windows 8 application?in my application i have to do code like this because i Develop automatically Email sending Application .if you find any other solution then please reply me ....
thnx for your help////
Thanks Farhan. I tried the code and it worked fine.
ReplyDeleteKind Regards
hi farhan do you know how to put new line in subject of mail ?
ReplyDeleteI tried with addinf "/n" but it is not working . If you have any idea please let me know.
Thanks
Try this "mailto:?to=recipient@example.com&subject=The subject of an email&body=This is first line%0D%0AThis is new line." You have to use "%0D%0A" in place of "\n"
ReplyDeleteYep... for security reasons and to avoid spamming, TCP/IP connections and any network usage in general will also be restricted soon... This "security" restrictions suck and put Microsoft and Win8/RT well behind competition.
ReplyDelete