0

我正在尝试在 Visual Studio 2008 中为 Windows Phone 创建一个简单的电子邮件发送应用程序,所以请告诉我必须使用哪些类或方法。

我试过了,但没有用:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Configuration;
using System.Xml;


      try
        {
            Application.DoEvents();
            // setup mail message
            MailMessage message = new MailMessage();
            message.From = new MailAddress(textBox1.Text);
            message.To.Add(new MailAddress(textBox2.Text));
            message.Subject = textBox3.Text;
            message.Body = textBox5.Text;

            // setup mail client
            SmtpClient mailClient = new SmtpClient("smtp.gmail.com");
            mailClient.Credentials = new NetworkCredential(textBox1.Text, textBox4.Text);
            mailClient.Send(message);

            MessageBox.Show("Sent");

        }
        catch (Exception)
        {
            MessageBox.Show("Error");
        }

我收到这些错误:

Error   1   The type or namespace name 'MailMessage' could not be found (are you missing a using directive or an assembly reference?)
Error   2   The type or namespace name 'MailMessage' could not be found (are you missing a using directive or an assembly reference?)
Error   3   The type or namespace name 'MailAddress' could not be found (are you missing a using directive or an assembly reference?)
Error   4   The type or namespace name 'MailAddress' could not be found (are you missing a using directive or an assembly reference?)
Error   5   The type or namespace name 'SmtpClient' could not be found (are you missing a using directive or an assembly reference?)
Error   6   The type or namespace name 'SmtpClient' could not be found (are you missing a using directive or an assembly reference?)
Error   7   The type or namespace name 'SmtpClient' could not be found (are you missing a using directive or an assembly reference?)
Error   8   The type or namespace name 'SmtpClient' could not be found (are you missing a using directive or an assembly reference?)
4

2 回答 2

1

.NET Compact 框架不支持 System.Net.Mail 或 System.Web.Mail。您可以使用诸如http://www.opennetcf.com/library/sdf/html/7e16eccb-dc9e-4559-c79c-cfaad631ac15.htm之类的扩展程序,或调用将代表您发送电子邮件的服务.

于 2012-09-28T06:28:21.333 回答
0

要在 windows mobile 上发送邮件等,您必须启动 VisualStudio C#/VB SmartDevice 项目。

可以通过命名空间 microsoft.windowsmobile.pocketoutlook 访问邮件等。您必须添加对包含 WindowsMo​​bile 程序集的 Windows Mobile 5(或更高版本)SDK 目录的引用。

http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.pocketoutlook.aspx

这是一个简单的片段,没有首先打开 poom 帐户等所需的东西:

http://cjcraft.com/blog/2008/10/02/how-to-open-a-mail-in-inbox-using-pocket-outlook/

于 2012-09-29T05:03:39.533 回答