使用EAGetMail组件从Gmail服务器读取电子邮件 [英] Read Email from Gmail Server using EAGetMail component

查看:208
本文介绍了使用EAGetMail组件从Gmail服务器读取电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从谷歌app.i中创建的gmail accout中读取邮件尝试阅读mail.connection已建立但电子邮件应该是0.



< pre lang =c#> MailServer oServer = new MailServer( pop.gmail.com alpha@convate.com,< span class =code-string> Siddhu @ 1,ServerProtocol.Pop3);
MailClient oClient = new MailClient( TryIt );

// 设置SSL连接,
oServer.SSLConnection = true ;

// 设置993 IMAP4端口
oServer.Port = 995 ;

尝试
{
oClient.Connect(oServer);
MailInfo [] infos = oClient.GetMailInfos();
MessageBox.Show(infos.Length.ToString());

for int i = 0 ; i < 信息。长度; i ++)
{
MailInfo info = infos [i];
Console.WriteLine( 索引:{0};大小:{1}; UIDL:{2}
info.Index,info.Size,info.UIDL);

// 从GMail IMAP4服务器下载电子邮件
Mail oMail = oClient.GetMail(info);
MessageBox.Show( From + oMail.From.ToString());
MessageBox.Show( Subject + oMail.Subject);
MessageBox.Show( body + oMail.TextBody);
oClient.Delete(info);
}

// 退出并从Gmail IMAP4服务器标记为已删除的纯电子邮件。
oClient.Quit();
}
catch (例外ep)
{
MessageBox.Show(ep.Message);
}

解决方案

参考 - C# - 从Gmail帐户中检索电子邮件 [ ^ ]。

引用:

因为Gmail POP3服务器没有像普通的POP3服务器一样工作,即使没有删除电子邮件也会自动隐藏旧电子邮件,因此我们建议您使用IMAP4协议。

请完成代码示例并使用 Gmail IMAP4 服务器。


/ *如何获取UNREAD EMAILS * /



MailClient oClient = new MailClient(TryIt);



oClient.GetMailInfosParam.GetMailInfosOptions = GetMailInfosOptionType.NewOnly;


i want to unread mail from gmail accout created in google app.i try to read the mail.connection is established but email it is should 0.

MailServer oServer = new MailServer("pop.gmail.com", "alpha@convate.com", "Siddhu@1", ServerProtocol.Pop3);
MailClient oClient = new MailClient("TryIt");

// Set SSL connection,
oServer.SSLConnection = true;

// Set 993 IMAP4 port
oServer.Port = 995;

try
{
    oClient.Connect(oServer);
    MailInfo[] infos = oClient.GetMailInfos();
 MessageBox.Show(infos.Length.ToString()); 

    for (int i = 0; i < infos.Length; i++)
    {
        MailInfo info = infos[i];
        Console.WriteLine("Index: {0}; Size: {1}; UIDL: {2}",
        info.Index, info.Size, info.UIDL);

        // Download email from GMail IMAP4 server
        Mail oMail = oClient.GetMail(info);
        MessageBox.Show("From" + oMail.From.ToString());
        MessageBox.Show("Subject" + oMail.Subject);
        MessageBox.Show("body" + oMail.TextBody);
        oClient.Delete(info);
    }

    // Quit and pure emails marked as deleted from Gmail IMAP4 server.
    oClient.Quit();
}
catch (Exception ep)
{
    MessageBox.Show(ep.Message);
}

解决方案

Refer - C# - Retrieve Email from Gmail Account[^].

Quote:

Because Gmail POP3 server doesn't work like normal POP3 server, it hides old emails automatically even the email was not deleted, so we suggest that you use IMAP4 protocol.

Please go through the code example and use Gmail IMAP4 server.


/*HOW TO GET Just the UNREAD EMAILS*/

MailClient oClient = new MailClient("TryIt");

oClient.GetMailInfosParam.GetMailInfosOptions = GetMailInfosOptionType.NewOnly;


这篇关于使用EAGetMail组件从Gmail服务器读取电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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