Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Its really frustating that EmailComposeTask doesn't have any way to send attachments. I googled this and found MailMessage dll. I don't know whether it is secure or not because user gonna send his password. Now I am thinking tot build my own service, send data from phone to service, and service will use smtp to send email with attachment. Now I want to ask, Am I right? What kind of service I use?
Posted

If you know your way through services, you're good to go. You can use a Windows Phone WCF service for that. Declare an send mail function in your service interface and implement something like
C#
...

public <type> sendmail(params)
{

...

    using (var client = new SmtpClient("smtp.gmail.com", 587))
    {
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.UseDefaultCredentials = false;
        client.EnableSsl = true;
        client.Credentials = new NetworkCredential("{yourusername}", "{yourpassword}");

        MailMessage message = new MailMessage();

        using (MemoryStream stream = new MemoryStream(new byte[{size}])) 
        {
    	    Attachment attachment = new Attachment(stream, "my attachment");
            message.Attachments.Add(attachment);
        }

        message.To.Add({"destinationemailaddress"});
        message.Subject = "{subject}";
        message.From = new MailAddress("youremailaddress");
        message.Body = "{body text}";

       client.Send(message);
    }
...

}

...
 
Share this answer
 
v3
Just use the MailMessage component for WP7 and WP8, it's available on geekchamp.com :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900