Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Reading emails from Gmail in C#

[TestMethod]
public void ReadImap()
{
    var mailRepository = new MailRepository(
                            "imap.gmail.com",
                            993,
                            true,
                            "yourEmailAddress@gmail.com",
                            "yourPassword"
                        );

    var emailList = mailRepository.GetAllMails("inbox");

    foreach (Message email in emailList)
    {
        Console.WriteLine("<p>{0}: {1}</p><p>{2}</p>", email.From, email.Subject, email.BodyHtml.Text);
        if (email.Attachments.Count > 0)
        {
            foreach (MimePart attachment in email.Attachments)
            {
                Console.WriteLine("<p>Attachment: {0} {1}</p>", attachment.ContentName, attachment.ContentType.MimeType);
            }
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: drawing default serializedproperty unity 
Csharp :: or operator in shell 
Csharp :: c# datagridview multiple row selection without control 
Csharp :: wpf binding ancestor codebehind 
Csharp :: c# trimend substring 
Csharp :: visual studio console.writeline not showing in output window 
Csharp :: c# builder pattern fluent example 
Csharp :: how to iterate a generic list in c# 
Csharp :: c# array to label 
Csharp :: asp net core dependency injection factory with parameters 
Csharp :: select a whole row out of a 2d array C# 
Csharp :: c# clear panel 
Csharp :: faucongz 
Csharp :: convert date to days c# 
Csharp :: oncollisionenter2d 
Csharp :: linq convert list to another list 
Csharp :: c# switch when 
Csharp :: copy-the-entire-contents-of-a-directory-in-c-sharp 
Csharp :: C# Convert xml to datatable 
Csharp :: convert bitmap to imagesource 
Csharp :: c# object add property 
Csharp :: How can I get my stripe customer ID? 
Csharp :: c# webclient vs httpclient 
Csharp :: non null array length 
Csharp :: create a hash of an XML c# 
Csharp :: c# bool? to bool 
Csharp :: c# different getter setter types 
Csharp :: deleting an item from a vector c# 
Csharp :: c# return statement 
Csharp :: c# Unit Test IDbContextFactory 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =