本文整理汇总了C#中OpenPop.Pop3.Pop3Client.Authenticate方法的典型用法代码示例。如果您正苦于以下问题:C# Pop3Client.Authenticate方法的具体用法?C# Pop3Client.Authenticate怎么用?C# Pop3Client.Authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenPop.Pop3.Pop3Client
的用法示例。
在下文中一共展示了Pop3Client.Authenticate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMethodInitialize
public void TestMethodInitialize()
{
settings = new TestSettings();
client = new Pop3Client();
client.Connect(settings.Pop3Server, settings.Pop3Port, settings.Pop3UseSSL);
client.Authenticate(settings.Pop3UserName, settings.Pop3Password);
}
示例2: ReadAllEmails
private void ReadAllEmails()
{
// The client disconnects from the server when being disposed
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(EmailConfiguration.Pop3, EmailConfiguration.PopPort, true, 1800, 1800, removeCertificateCallback);
// Authenticate ourselves towards the server
client.Authenticate(EmailConfiguration.Email, EmailConfiguration.EmailPwd);
// Get the number of messages in the inbox
int messageCount = client.GetMessageCount();
_systemLogger.Tell(string.Format("Total messages found: {0}", messageCount));
// Most servers give the latest message the highest number
for (int i = messageCount; i > 0; i--)
{
var msg = client.GetMessage(i);
// Now return the fetched messages
_emailProcessorActor.Tell(new EmailMessage(){Subject = msg.Headers.Subject, Date = msg.Headers.Date});
}
}
}
示例3: Test
public void Test()
{
const string hostName = "pop.gmail.com";
int port = 995;
bool useSsl = true;
string userName = "USER";
string password = "PASSWORD";
using(Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostName, port, useSsl);
// Authenticate ourselves towards the server
client.Authenticate(userName, password);
// Get the number of messages in the inbox
int messageCount = client.GetMessageCount();
// We want to download all messages
List<Message> allMessages = new List<Message>(messageCount);
// Messages are numbered in the interval: [1, messageCount]
// Ergo: message numbers are 1-based.
// Most servers give the latest message the highest number
for (int i = messageCount; i > 0; i--)
{
allMessages.Add(client.GetMessage(i));
}
allMessages.ForEach(m=>Console.WriteLine("Display name: {0}", m.Headers.From.DisplayName));
}
}
示例4: FetchAllMessages
public void FetchAllMessages()
{
// The client disconnects from the server when being disposed
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(_hostName, _port, true);
// Authenticate ourselves towards the server
client.Authenticate(_username, _password);
// Get the number of messages in the inbox
int messageCount = client.GetMessageCount();
// We want to download all messages
List<Message> allMessages = new List<Message>(messageCount);
// Messages are numbered in the interval: [1, messageCount]
// Ergo: message numbers are 1-based.
for (int i = 1; i <= messageCount; i++)
{
allMessages.Add(client.GetMessage(i));
}
}
}
示例5: GetAllMessages
//Connect to gmail, get emails and ad it to a MessageList
public static List<OpenPop.Mime.Message> GetAllMessages(string hostname, int port, bool ssl, string username, string password)
{
try
{
Pop3Client client = new Pop3Client();
if (client.Connected)
{
client.Disconnect();
}
client.Connect(hostname, port, ssl);
client.Authenticate(username, password);
int messageCount = client.GetMessageCount();
List<OpenPop.Mime.Message> allMessages = new List<OpenPop.Mime.Message>(messageCount);
for (int i = messageCount; i > messageCount - 5; i--)
{
allMessages.Add(client.GetMessage(i));
}
return allMessages;
}
catch(Exception ex)
{
MessageBox.Show("You have written username or password wrong or something else has happened! Program will not keep going, please open it again, thank you : " + ex.Message);
Thread.CurrentThread.Abort();
//EmailClient.
}
return null;
}
示例6: HasMessages
public override bool HasMessages()
{
if (!pop3Client.Connected)
{
pop3Client.Dispose();
pop3Client = new Pop3Client();
pop3Client.Connect(HostName, Port, useSSL);
pop3Client.Authenticate(Login, Password);
}
if (0 >= index)
{
index = count = pop3Client.GetMessageCount();
if (0 == index)
{
pop3Client.Disconnect();
pop3Client.Dispose();
pop3Client = new Pop3Client();
pop3Client.Connect(HostName, Port, useSSL);
pop3Client.Authenticate(Login, Password);
}
//for (int i = count; i >= 1; i -= 1)
}
return 0 < index;
}
示例7: FetchAllMessages
/// <summary>
/// Example showing:
/// - how to fetch all messages from a POP3 server
/// </summary>
/// <param name="hostname">Hostname of the server. For example: pop3.live.com</param>
/// <param name="port">Host port to connect to. Normally: 110 for plain POP3, 995 for SSL POP3</param>
/// <param name="useSsl">Whether or not to use SSL to connect to server</param>
/// <param name="username">Username of the user on the server</param>
/// <param name="password">Password of the user on the server</param>
/// <returns>All Messages on the POP3 server</returns>
public static List<Message> FetchAllMessages(string hostname, int port, bool useSsl, string username, string password)
{
// The client disconnects from the server when being disposed
using(Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
// Authenticate ourselves towards the server
client.Authenticate(username, password);
// Get the number of messages in the inbox
int messageCount = client.GetMessageCount();
// We want to download all messages
List<Message> allMessages = new List<Message>(messageCount);
// Messages are numbered in the interval: [1, messageCount]
// Ergo: message numbers are 1-based.
// Most servers give the latest message the highest number
for (int i = messageCount; i > 0; i--)
{
allMessages.Add(client.GetMessage(i));
}
// Now return the fetched messages
return allMessages;
}
}
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
using (Pop3Client client = new Pop3Client())
{
//Para conectar no servidor do gmail use a porta 995 e SSL
client.Connect("pop.gmail.com", 995, true);
//Para conectar no servidor do hotmail use a porta 995 e SSL
//client.Connect("pop3.live.com", 995, true);
//usuário e senha para autenticar
client.Authenticate("luisfelipe.lambert", "sakuda5G");
//Pega o número de mensagens
int messageCount = client.GetMessageCount();
//Instanciar a lista
List<Message> mensagens = new List<Message>();
//Pegar as mensagens
for (int i = messageCount; i > 0; i--)
{
//Adicionar a mensagem a lista
mensagens.Add(client.GetMessage(i));
}
//Popular o repeater com as mensagens
repMensagens.DataSource = mensagens;
repMensagens.DataBind();
}
}
catch (Exception ex)
{
//Caso ocorra algum erro, uma mensagem será exibida na página
litMensagemErro.Text = ex.ToString();
}
}
示例9: GetAllMails
/* Function to retrive Email from the POP3 Server */
public void GetAllMails(object sender, DoWorkEventArgs e)
{
int percentComplete;
using(Pop3Client client = new Pop3Client())
{
/* Set the Server, Port, ssl and username/password */
client.Connect(Setting.Default.pop3_server, Setting.Default.pop3_port, Setting.Default.smtp_ssl);
client.Authenticate(Setting.Default.username, Setting.Default.password);
int messageCount = client.GetMessageCount();
Debug.WriteLine(messageCount);
/* Create a list to contain the messages */
List<Message> allMessages = new List<Message>();
/* A loop to calculate the progress of retriving the Emails */
for (int i = messageCount; i > 0; i--)
{
allMessages.Add(client.GetMessage(i));
percentComplete = Convert.ToInt16((Convert.ToDouble(allMessages.Count) / Convert.ToDouble(messageCount)) * 100);
(sender as BackgroundWorker).ReportProgress(percentComplete);
}
e.Result = allMessages;
}
}
示例10: processMail
public void processMail()
{
Logger.info("Проверка почты: ");
try {
Pop3Client client = new Pop3Client();
client.Connect(Settings.Single.smtpServer, 110, false);
client.Authenticate(Settings.Single.smtpUser, Settings.Single.smtpPassword);
List<string> msgs = client.GetMessageUids();
Logger.info(String.Format("Получено {0} сообщений ", msgs.Count));
for (int i = 0; i < msgs.Count; i++) {
try {
Logger.info("Чтение письма " + i.ToString());
Message msg = client.GetMessage(i);
List<MessagePart> files = msg.FindAllAttachments();
Logger.info(String.Format("Прикреплено {0} файлов", files.Count));
if (files.Count == 1) {
Logger.info(String.Format("Обработка файла {0}", files[0].FileName));
MessagePart file = files[0];
string pbrData = file.GetBodyAsText();
PBR.getFromText(pbrData);
}
}
catch (Exception e) {
Logger.error("Ошибка при обработке письма " + i);
}
}
}
catch (Exception e) {
Logger.error("Ошибка при работе с почтой " + e.ToString());
}
}
示例11: ConnectToPop3
private void ConnectToPop3()
{
client = new Pop3Client();
client.Connect(settings.Pop3Server, settings.Pop3Port, settings.Pop3UseSSL);
client.Authenticate(settings.Pop3UserName, settings.Pop3Password);
}
示例12: fetchAllMessages
private static void fetchAllMessages(object sender, DoWorkEventArgs e)
{
int percentComplete;
// The client disconnects from the server when being disposed
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
//client.Connect("pop.gmail.com", 995, true);
client.Connect("mail1.stofanet.dk", 110, false);
// Authenticate ourselves towards the server
client.Authenticate("2241859m002", "big1234");
// Get the number of messages in the inbox
int messageCount = client.GetMessageCount();
// We want to download all messages
List<OpenPop.Mime.Message> allMessages = new List<OpenPop.Mime.Message>(messageCount);
// Messages are numbered in the interval: [1, messageCount]
// Ergo: message numbers are 1-based.
// Most servers give the latest message the highest number
for (int i = messageCount; i > 0; i--)
{
allMessages.Add(client.GetMessage(i));
percentComplete = Convert.ToInt16((Convert.ToDouble(allMessages.Count) / Convert.ToDouble(messageCount)) * 100);
(sender as BackgroundWorker).ReportProgress(percentComplete);
}
// Now return the fetched messages
e.Result = allMessages;
}
}
示例13: ImportEmails
//-------------------------------------------------------------------------------------------
private void ImportEmails(Communication_EmailAccounts account)
{
Console.WriteLine("Importing e-mails for " + account.Id + " -- " + account.Host);
using (Pop3Client client = new Pop3Client())
{
// connect
client.Connect(account.Host, account.Port, (account.Type == "pops"));
client.Authenticate(account.Username, account.Password);
// iterate over the messages
int messageCount = client.GetMessageCount();
List<Message> allMessages = new List<Message>(messageCount);
for (int i = 1; i <= messageCount; i++)
{
using (WeavverEntityContainer data = new WeavverEntityContainer())
{
//data.SearchAllTables("asdf");
// save to database
Message m = (Message) client.GetMessage(i);
if (m.MessagePart.IsText)
{
Communication_Emails item = new Communication_Emails();
item.From = m.Headers.From.Raw;
item.Subject = m.Headers.Subject;
item.Raw = System.Text.ASCIIEncoding.ASCII.GetString(m.RawMessage);
data.SaveChanges();
client.DeleteMessage(i);
}
}
}
}
}
示例14: CallDataProviderImplPop3
public CallDataProviderImplPop3(ISelectorConfig config)
: base(config)
{
this.pop3Client = new Pop3Client();
pop3Client.Connect(HostName, Port, useSSL);
pop3Client.Authenticate(Login, Password);
NULL_MESSAGE = new CallMessageImpl(pop3Client, 0, this);
}
示例15: GetMessages
public IEnumerable<MessageDTO> GetMessages(string hostname, int port, bool useSsl, string username,
string password, int? maxNumber = null)
{
var allMessages = new List<MessageDTO>();
try
{
// The client disconnects from the server when being disposed
using (var client = new Pop3Client())
{
client.Connect(hostname, port, useSsl);
client.Authenticate(username, password, AuthenticationMethod.UsernameAndPassword);
var maxCount = client.GetMessageCount();
//work out subset to take from messages
var messageCount = (maxNumber.HasValue && maxNumber < maxCount) ? (maxCount - maxNumber.Value) : 0;
//message list is 1 based
//loop written backwards so messages are in correct order
for (var i = maxCount; i > messageCount; i--)
{
var currentMessage = client.GetMessage(i);
var html = currentMessage.FindFirstHtmlVersion();
allMessages.Add(new MessageDTO
{
Body =
html != null && html.Body != null
? Encoding.UTF8.GetString(html.Body)
: string.Empty,
DateSent = currentMessage.Headers.DateSent,
DisplayName = currentMessage.Headers.From.DisplayName,
From = currentMessage.Headers.From.Address,
Id = currentMessage.Headers.MessageId,
Subject = currentMessage.Headers.Subject,
Uid = currentMessage.Headers.MessageId
});
}
}
}
catch (Exception ex)
{
var path = Path.GetTempPath();
var stream = File.OpenWrite(Path.Combine(path, "mailFireErrorLog.log"));
using (var fileWriter = new StreamWriter(stream))
{
fileWriter.Write(string.Format("Exception occurred: {0} - at {1}", ex.Message, DateTime.Now));
}
}
return allMessages;
}