有没有办法在Windows Phone中发送带附件的电子邮件 [英] Is there any way to send email with attachment in windows phone

查看:92
本文介绍了有没有办法在Windows Phone中发送带附件的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EmailComposeTask没有任何方式发送附件真的很令人沮丧。我用Google搜索并找到了MailMessage dll。我不知道它是否安全,因为用户会发送他的密码。现在我正在考虑建立自己的服务,从手机发送数据到服务,服务将使用smtp发送带附件的电子邮件。现在我想问,我是对的吗?我使用什么样的服务?

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?

推荐答案

如果你了解自己的服务方式,那么你很高兴。您可以使用Windows Phone WCF服务。在您的服务界面中声明发送邮件功能并实现类似
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
...

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);
    }
...

}

...


只需将WPM和WP8的MailMessage组件用于geekchamp.com即可:)
Just use the MailMessage component for WP7 and WP8, it's available on geekchamp.com :)


这篇关于有没有办法在Windows Phone中发送带附件的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆