<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lesnikowski Blog &#187; Component</title>
	<atom:link href="http://www.lesnikowski.com/blog/index.php/category/component/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lesnikowski.com/blog</link>
	<description>.Net</description>
	<lastBuildDate>Wed, 28 Jul 2010 10:10:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sign emails with DKIM</title>
		<link>http://www.lesnikowski.com/blog/index.php/sign-emails-with-dkim/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sign-emails-with-dkim</link>
		<comments>http://www.lesnikowski.com/blog/index.php/sign-emails-with-dkim/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 16:05:02 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DKIM]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=1008</guid>
		<description><![CDATA[DKIM is short for DomainKeys Identified Mail. 
Adding a signature looks like this:

// C#

using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
   IMail email = Mail
       .Text(&#34;text&#34;)
       .From(&#34;alice@mail.com&#34;)
       .To(&#34;bob@mail.com&#34;)
       .Subject(&#34;subject&#34;)
   [...]]]></description>
			<content:encoded><![CDATA[<p>DKIM is short for DomainKeys Identified Mail. </p>
<p>Adding a signature looks like this:</p>
<pre class="brush: csharp;">
// C#

using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
   IMail email = Mail
       .Text(&quot;text&quot;)
       .From(&quot;alice@mail.com&quot;)
       .To(&quot;bob@mail.com&quot;)
       .Subject(&quot;subject&quot;)
       .DKIMSign(rsa, &quot;brisbane&quot;, &quot;example.com&quot;)
       .Create();
}
</pre>
<pre class="brush: vb;">
' VB.NET

Using rsa As New RSACryptoServiceProvider()
	Dim email As IMail = Mail _
		.Text(&quot;text&quot;) _
		.From(&quot;alice@mail.com&quot;) _
		.[To](&quot;bob@mail.com&quot;) _
		.Subject(&quot;subject&quot;) _
		.DKIMSign(rsa, &quot;brisbane&quot;, &quot;example.com&quot;) _
		.Create()
End Using
</pre>
<p>So what you need is RSACryptoServiceProvider with your private key, and two strings: selector and domain.</p>
<p>Basically how this works is the recipient of the email queries the DNS server for TXT record for selector._domainkey.domain (in our sample it is: &#8220;brisbane._domainkey.example.com&#8221;) to get the public key and validate the signature.</p>
<p>You can use <strong>nslookup </strong>to get the public key for a domain:</p>
<pre class="brush: plain;">
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Pawel&gt;nslookup
Default Server:  UnKnown
Address:  192.168.0.1

&gt; set type=TXT
&gt; gamma._domainkey.gmail.com
Server:  UnKnown
Address:  192.168.0.1

Non-authoritative answer:
gamma._domainkey.gmail.com      text =

        &quot;k=rsa; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIhyR3oItOy22ZOaBrI
Ve9m/iME3RqOJeasANSpg2YTHTYV+Xtp4xwf5gTjCmHQEMOs0qYu0FYiNQPQogJ2t0Mfx9zNu06rfRBD
jiIU9tpx2T+NGlWZ8qhbiLo5By8apJavLyqTLavyPSrvsx0B3YzC63T4Age2CDqZYA+OwSMWQIDAQAB&quot;

gmail.com       nameserver = ns1.google.com
gmail.com       nameserver = ns4.google.com
gmail.com       nameserver = ns3.google.com
gmail.com       nameserver = ns2.google.com
ns1.google.com  internet address = 216.239.32.10
ns2.google.com  internet address = 216.239.34.10
ns3.google.com  internet address = 216.239.36.10
ns4.google.com  internet address = 216.239.38.10
&gt;
</pre>
<p>But don&#8217;t worry as <strong>Mail.dll will make this DNS </strong>query for you.</p>
<p>Validating (including DNS query for public key) is simple:</p>
<pre class="brush: csharp;">
// C#

IMail email = new MailBuilder()
    .CreateFromEmlFile(&quot;signed_gamma.gmail.eml&quot;);
bool isValid = email.CheckDKIMSignature();
</pre>
<pre class="brush: vb;">
' VB.NET

Dim email As IMail = New MailBuilder() _
    .CreateFromEmlFile(&quot;signed_gamma.gmail.eml&quot;)
Dim isValid As Boolean = email.CheckDKIMSignature()
</pre>
<p>You can <a href="http://www.lesnikowski.com/mail/">download Mail.dll .NET email component here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/sign-emails-with-dkim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The handshake failed due to an unexpected packet format</title>
		<link>http://www.lesnikowski.com/blog/index.php/the-handshake-failed-due-to-an-unexpected-packet-format/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=the-handshake-failed-due-to-an-unexpected-packet-format</link>
		<comments>http://www.lesnikowski.com/blog/index.php/the-handshake-failed-due-to-an-unexpected-packet-format/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 16:59:37 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[POP3]]></category>
		<category><![CDATA[SMTP]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=1009</guid>
		<description><![CDATA[Most likely your server requires implicit SSL. So first try to connect without SSL:

// C#

client.Connect(&#34;imap.example.com&#34;);


' VB.NET

client.Connect(&#34;imap.example.com&#34;);

Then, before logging-in, start implicit SSL negotiation. The command name differs for different protocols:
In case of IMAP:

// C#

client.StartTLS();


' VB.NET

client.StartTLS()

In case of POP3:

// C#

client.STLS();


' VB.NET

client.STLS()

In case of SMTP:

// C#

client.StartTLS();


' VB.NET

client.StartTLS()

Now, your connection is secured. 
Remember that you can ignore SSL certificate [...]]]></description>
			<content:encoded><![CDATA[<p>Most likely your server requires <strong>implicit </strong>SSL. So first try to connect without SSL:</p>
<pre class="brush: csharp;">
// C#

client.Connect(&quot;imap.example.com&quot;);
</pre>
<pre class="brush: vb;">
' VB.NET

client.Connect(&quot;imap.example.com&quot;);
</pre>
<p>Then, before logging-in, <strong>start implicit SSL negotiation</strong>. The command name differs for different protocols:</p>
<p>In case of <strong>IMAP</strong>:</p>
<pre class="brush: csharp;">
// C#

client.StartTLS();
</pre>
<pre class="brush: vb;">
' VB.NET

client.StartTLS()
</pre>
<p>In case of <strong>POP3</strong>:</p>
<pre class="brush: csharp;">
// C#

client.STLS();
</pre>
<pre class="brush: vb;">
' VB.NET

client.STLS()
</pre>
<p>In case of <strong>SMTP</strong>:</p>
<pre class="brush: csharp;">
// C#

client.StartTLS();
</pre>
<pre class="brush: vb;">
' VB.NET

client.StartTLS()
</pre>
<p>Now,<strong> your connection is secured</strong>. </p>
<p>Remember that you can ignore<strong> SSL certificate errors</strong> using <em>ServerCertificateValidate </em>event:</p>
<pre class="brush: csharp;">
// C#

client.ServerCertificateValidate +=
    (sender, e) =&gt; { e.IsValid = true; };
</pre>
<pre class="brush: vb;">
' VB.NET

client.ServerCertificateValidate += Function(sender, e) Do
	e.IsValid = True
End Function
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/the-handshake-failed-due-to-an-unexpected-packet-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Download parts of email message</title>
		<link>http://www.lesnikowski.com/blog/index.php/download-parts-of-email-message/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=download-parts-of-email-message</link>
		<comments>http://www.lesnikowski.com/blog/index.php/download-parts-of-email-message/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 16:26:35 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=984</guid>
		<description><![CDATA[Some times you know you&#8217;ll receive large emails, but you only need to access some parts without downloading entire messages .
Mail.dll .NET IMAP client allows you to download only needed parts of the specified message.
First you need to get the structure of the message.
There are two methods for that: GetBodyStructureByUID and GetBodyStructure.
BodyStructure contains information about [...]]]></description>
			<content:encoded><![CDATA[<p>Some times you know you&#8217;ll receive large emails, but <strong>you only need to access some parts without downloading entire messages</strong> .</p>
<p><a href="http://www.lesnikowski.com/mail/">Mail.dll .NET IMAP client</a> allows you to download only needed parts of the specified message.</p>
<p>First you need to get the <strong>structure </strong>of the message.<br />
There are two methods for that: GetBodyStructureByUID and GetBodyStructure.</p>
<p><strong>BodyStructure </strong>contains information about plain text, html, and all attachments of the message. It does not contain any data though.</p>
<p>To <strong>download text</strong> parts of the email (like html or plain text) you can use: GetMimePartTextByUID or GetMimePartText.</p>
<p>To <strong>download attachments</strong> use: GetMimePartByUID or GetMimePart.</p>
<p>Here&#8217;s the full sample for this feature:</p>
<pre class="brush: csharp;">
// C#

using(Imap imap = new Imap())
{
	imap.Connect(&quot;imap.server.com&quot;);
	imap.Login(&quot;user&quot;, &quot;password&quot;);

	imap.SelectInbox();
	List&lt;long&gt; uidList = imap.SearchFlag(Flag.Unseen);
	foreach (long uid in uidList)
	{
		// Get the structure of the email
		BodyStructure structure = imap.GetBodyStructureByUID(uid);

		// Download only text and html parts
		string text = imap.GetMimePartTextByUID(uid, structure.Text);
		string html = imap.GetMimePartTextByUID(uid, structure.Html);

		Console.WriteLine(text);
		Console.WriteLine(html);

		// Show all attachments' filenames
		foreach(MimeStructure attachment in structure.Attachments)
		{
			Console.WriteLine(attachment.FileName);
			// You can also download entire attachment
			byte[] bytes = imap.GetMimePartByUID(uid, attachment);
		}
	}
	imap.Close(true);
}
</pre>
<pre class="brush: vb;">
' VB.NET

Using imap As New Imap()
	imap.Connect(&quot;imap.server.com&quot;)
	imap.Login(&quot;user&quot;, &quot;password&quot;)

	imap.SelectInbox()
	Dim uidList As List(Of Long) = imap.SearchFlag(Flag.Unseen)
	For Each uid As Long In uidList
		' Get the structure of the email
		Dim struct As BodyStructure = imap.GetBodyStructureByUID(uid)

		' Download only text and html parts
		Dim text As String = imap.GetMimePartTextByUID(
			uid, struct.Text)
		Dim html As String = imap.GetMimePartTextByUID(
			uid, struct.Html)

		Console.WriteLine(text)
		Console.WriteLine(html)

		' Show all attachments' filenames
		For Each attachment As MimeStructure In struct.Attachments
			Console.WriteLine(attachment.FileName)
			' You can also download entire attachment
			Dim bytes As Byte() = imap.GetMimePartByUID(
				uid, attachment)
		Next
	Next
	imap.Close(True)
End Using
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/download-parts-of-email-message/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Peek message on IMAP server</title>
		<link>http://www.lesnikowski.com/blog/index.php/peek-message-on-imap-server/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=peek-message-on-imap-server</link>
		<comments>http://www.lesnikowski.com/blog/index.php/peek-message-on-imap-server/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 15:00:42 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=978</guid>
		<description><![CDATA[When you access messages stored on IMAP  server, it automatically adds \Seen flag to the messages you have downloaded.
If you don&#8217;t want this behavior, there are two things you can do.
First is to use Examine method instead of Select:

// C#

using(Imap imap = new Imap())
{
    imap.Connect(&#34;imap.server.com&#34;);
    imap.Login(&#34;user&#34;, &#34;password&#34;);

  [...]]]></description>
			<content:encoded><![CDATA[<p>When you access messages stored on <strong>IMAP </strong> server, it <strong>automatically adds \Seen flag</strong> to the messages you have downloaded.</p>
<p>If you don&#8217;t want this behavior, there are two things you can do.</p>
<p>First is to use <strong>Examine </strong>method instead of Select:</p>
<pre class="brush: csharp;">
// C#

using(Imap imap = new Imap())
{
    imap.Connect(&quot;imap.server.com&quot;);
    imap.Login(&quot;user&quot;, &quot;password&quot;);

    imap.ExamineInbox(); // -or- imap.Examine(&quot;Inbox&quot;);

    // ...

    imap.Close(true);
}
</pre>
<pre class="brush: vb;">
' VB.NET

Using imap As New Imap
    imap.Connect(&quot;imap.server.com&quot;)
    imap.Login(&quot;user&quot;, &quot;password&quot;)

    imap.SelectInbox()

    imap.ExamineInbox() ' -or- imap.Examine(&quot;Inbox&quot;)

    ' ...

    imap.Close(True)
End Using
</pre>
<p>Examine puts mailbox (also called folder) into read-only state, so no \Seen flag is added.<br />
The drawback is that you can not delete a message.</p>
<p>Second approach is to use one of the <strong>Peek</strong> methods on the IMAP client:</p>
<pre class="brush: csharp;">
// C#

using(Imap imap = new Imap())
{
    imap.Connect(&quot;imap.server.com&quot;);
    imap.Login(&quot;user&quot;, &quot;password&quot;);

    imap.SelectInbox();
    List&lt;long&gt; uidList = imap.SearchFlag(Flag.Unseen);
    foreach (long uid in uidList)
    {
        IMail email = new MailBuilder()
            .CreateFromEml(imap.PeekMessageByUID(uid));
        Console.WriteLine(email.Subject);
    }
    imap.Close(true);
}
</pre>
<pre class="brush: vb;">
' VB.NET

Using imap As New Imap
    imap.Connect(&quot;imap.server.com&quot;)
    imap.Login(&quot;user&quot;, &quot;password&quot;)

    imap.SelectInbox()
    Dim uidList As List(Of Long) = imap.SearchFlag(Flag.Unseen)

    For Each uid As Long In uidList
        Dim email As IMail = New MailBuilder() _
            .CreateFromEml(imap.PeekMessageByUID(uid))
        Console.WriteLine(email.Subject)
    Next
    imap.Close(True)
End Using
</pre>
<p>There are <strong>Peek </strong>methods for downloading headers and even parts of the email message.</p>
<p>You can download <a href="http://www.lesnikowski.com/mail/">Mail.dll IMAP client here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/peek-message-on-imap-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OAuth with IMAP</title>
		<link>http://www.lesnikowski.com/blog/index.php/oauth-with-imap/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=oauth-with-imap</link>
		<comments>http://www.lesnikowski.com/blog/index.php/oauth-with-imap/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 19:44:43 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[GMail]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[OAuth]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=936</guid>
		<description><![CDATA[ OAuth is an open protocol to allow secure API authorization in a simple and standard method from desktop and web applications.
In this post I&#8217;ll show how to access GMail account using OAuth authentication method. The key advantage of this method is that it allows an application to access users email without knowing user&#8217;s password.
You [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2009/11/gmail.png" alt="" title="gmail" width="131" height="61" class="alignleft size-full wp-image-271" /> OAuth is an open protocol to allow secure API authorization in a simple and standard method from desktop and web applications.</p>
<p>In this post<strong> I&#8217;ll show how to access GMail</strong> account using OAuth authentication method. The key advantage of this method is that it allows an application to access users email <strong>without knowing user&#8217;s password.</strong></p>
<p>You can read more on OAuth authentication with Google accounts here:<br />
<a href="http://code.google.com/apis/accounts/docs/OAuth_ref.html">http://code.google.com/apis/accounts/docs/OAuth_ref.html</a></p>
<p>Gmail IMAP and SMTP using OAuth:<br />
<a href="http://code.google.com/apis/gmail/oauth/protocol.html">http://code.google.com/apis/gmail/oauth/protocol.html</a></p>
<p>If your application is not registered, please select HMAC-SHA1 and use the following key and secret:<br />
consumer key: &#8220;anonymous&#8221;<br />
consumer secret: &#8220;anonymous&#8221;</p>
<p>You can manage your domains here:<br />
<a href="https://www.google.com/accounts/ManageDomains">https://www.google.com/accounts/ManageDomains</a></p>
<p>The following code makes <strong>several HTTP requests</strong> to authenticate your application. It also <strong>fires up the web browser, so the user can allow or deny</strong> the application to access his emails.</p>
<pre class="brush: csharp;">
const string userEmailAccount = &quot;alice@gmail.com&quot;;
const string consumerKey = &quot;anonymous&quot;;
const string consumerSecret = &quot;anonymous&quot;;

// First: get request token
ParameterList parameters1 = OAuth.ForUrl(
        &quot;https://www.google.com/accounts/OAuthGetRequestToken&quot;)
    .Consumer(consumerKey, consumerSecret)
    .AddParameter(&quot;scope&quot;, &quot;https://mail.google.com/&quot;)
    .AddParameter(OAuthParameterName.OAuthCallback, &quot;oob&quot;)
    .Sign()
    .ExecuteWebRequest();

// Second: user interaction
string url2 = OAuth.ForUrl(
        &quot;https://www.google.com/accounts/OAuthAuthorizeToken&quot;)
   .Consumer(consumerKey, consumerSecret)
   .Token(parameters1.GetValue(OAuthParameterName.OAuthToken))
   .TokenSecret(parameters1.GetValue(OAuthParameterName.OAuthTokenSecret))
   .Sign()
   .GetUrl();

// Fire up the browser
Process.Start(url2);
Console.WriteLine(&quot;Please enter the key: &quot;);
string key = Console.ReadLine().Trim();

// Third: get access token
ParameterList parameters3 = OAuth.ForUrl(
        &quot;https://www.google.com/accounts/OAuthGetAccessToken&quot;)
   .Consumer(consumerKey, consumerSecret)
   .Token(parameters1.GetValue(OAuthParameterName.OAuthToken))
   .TokenSecret(parameters1.GetValue(OAuthParameterName.OAuthTokenSecret))
   .AddParameter(&quot;oauth_verifier&quot;, key)
   .Sign()
   .ExecuteWebRequest();

// Log-in to IMAP server using XOAuth
using (Imap client = new Imap())
{
    client.ConnectSSL(TestConstants.GmailImapServer);

    string imapUrl = string.Format(
        &quot;https://mail.google.com/mail/b/{0}/imap/&quot;, userEmailAccount);

    string oauthImapKey = OAuth.ForUrl(imapUrl)
        .Consumer(consumerKey, consumerSecret)
        .Token(parameters3.GetValue(OAuthParameterName.OAuthToken))
        .TokenSecret(parameters3.GetValue(OAuthParameterName.OAuthTokenSecret))
        .Sign()
        .GetXOAuthKey();

    client.LoginOAUTH(oauthImapKey);

    // Now you can access user's emails.

    client.Close(true);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/oauth-with-imap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free Yahoo! Mail via IMAP</title>
		<link>http://www.lesnikowski.com/blog/index.php/free-yahoo-mail-via-imap/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=free-yahoo-mail-via-imap</link>
		<comments>http://www.lesnikowski.com/blog/index.php/free-yahoo-mail-via-imap/#comments</comments>
		<pubDate>Sun, 30 May 2010 09:59:33 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IDLE]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Yahoo!]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=911</guid>
		<description><![CDATA[It is possible to get direct Yahoo! IMAP access.
Yahoo! operates IMAP servers (imap.mail.yahoo.com in particular), which are globally accessible. 
However they require a specific, but non-standard IMAP command to be sent before login is done. The command is: “ID (&#8220;GUID&#8221; &#8220;1&#8243;)” 

// C#
imap.SendCommand(@&#34;ID (&#34;&#34;GUID&#34;&#34; &#34;&#34;1&#34;&#34;)&#34;);


' VB
imap.SendCommand(&#34;ID (&#34;&#34;GUID&#34;&#34; &#34;&#34;1&#34;&#34;)&#34;)

There is also an IMAP server running at [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2010/05/yahoo.gif" alt="" title="yahoo" width="142" height="38" class="alignleft size-full wp-image-917" />It is possible to get direct Yahoo! IMAP access.<br />
Yahoo! operates IMAP servers (imap.mail.yahoo.com in particular), which are globally accessible. </p>
<p>However <strong>they require a specific, but non-standard IMAP command to be sent before login</strong> is done. The command is: “ID (&#8220;GUID&#8221; &#8220;1&#8243;)” </p>
<pre class="brush: csharp;">
// C#
imap.SendCommand(@&quot;ID (&quot;&quot;GUID&quot;&quot; &quot;&quot;1&quot;&quot;)&quot;);
</pre>
<pre class="brush: vb;">
' VB
imap.SendCommand(&quot;ID (&quot;&quot;GUID&quot;&quot; &quot;&quot;1&quot;&quot;)&quot;)
</pre>
<p>There is also an IMAP server running at imap-ssl.mail.yahoo.com; it uses <strong>SSL</strong> on the standard port 993.</p>
<p>Here&#8217;s the full <strong>C#</strong> version of the code:</p>
<pre class="brush: csharp;">
using (Imap imap = new Imap())
{
    imap.Connect(&quot;imap.mail.yahoo.com&quot;);
    imap.SendCommand(@&quot;ID (&quot;&quot;GUID&quot;&quot; &quot;&quot;1&quot;&quot;)&quot;);

	imap.Login(&quot;user&quot;, &quot;password&quot;);

	imap.SelectInbox();
	List&lt;long&gt; uidList = imap.Search(Expression.All());
	foreach (long uid in uidList)
	{
		IMail email = new MailBuilder()
    			.CreateFromEml(imap.GetMessageByUID(uid));
		Console.WriteLine(email.Subject);
	}
	imap.Close(true);
}
</pre>
<p>and <strong>VB.NET</strong> version:</p>
<pre class="brush: vb;">
Using imap As New Imap()
	imap.Connect(&quot;imap.mail.yahoo.com&quot;)
	imap.SendCommand(&quot;ID (&quot;&quot;GUID&quot;&quot; &quot;&quot;1&quot;&quot;)&quot;)

	imap.Login(&quot;user&quot;, &quot;password&quot;)

	imap.SelectInbox()
	Dim uidList As List(Of Long) = imap.Search(Expression.All())
	For Each uid As Long In uidList
		Dim email As IMail = New MailBuilder() _
			.CreateFromEml(imap.GetMessageByUID(uid))
		Console.WriteLine(email.Subject)
	Next
	imap.Close(True)
End Using
</pre>
<p>Differences:<br />
- non-standard command ID command is required before any other command.<br />
- Examine explicitly requires CLOSE command (Imap.CloseCurrentFolder), otherwise subsequent SELECT (Imap.Select) has no effect and mailbox is still in read-only state<br />
- IDLE is not implemented.<br />
- SELECT for not existing folder does not create new folder.</p>
<p>You can download the latest version of <a href="http://www.lesnikowski.com/mail/">Mail.dll .NET IMAP client here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/free-yahoo-mail-via-imap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Send iCalendar meeting requests</title>
		<link>http://www.lesnikowski.com/blog/index.php/send-icalendar-meeting-requests/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=send-icalendar-meeting-requests</link>
		<comments>http://www.lesnikowski.com/blog/index.php/send-icalendar-meeting-requests/#comments</comments>
		<pubDate>Mon, 10 May 2010 18:00:42 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[iCalendar]]></category>
		<category><![CDATA[Mail.dll]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=886</guid>
		<description><![CDATA[
Mail.dll .NET email component has support for popular iCalendar standard.
iCalendar is used by most popular email clients like Outlook or GMail. It allows Internet users to send meeting requests and tasks to other Internet users, via email, or sharing files with an extension of .ics. 
Recipients of the iCalendar data file (with supporting software, such [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2010/05/iCalendar.jpg" alt="" title="iCalendar" width="128" height="128" class="alignleft size-full wp-image-891" /></p>
<p><a href="http://www.lesnikowski.com/mail/">Mail.dll .NET email component</a> has support for popular iCalendar standard.</p>
<p><strong>iCalendar</strong> is used by most popular email clients like Outlook or GMail. It allows Internet users to send meeting requests and tasks to other Internet users, via email, or sharing files with an extension of .ics. </p>
<p>Recipients of the iCalendar data file (with supporting software, such as an email client or calendar application) can respond to the sender easily or counter propose another meeting date/time.</p>
<p>First make sure that your &#8216;usings&#8217; or &#8216;Imports&#8217; section includes all needed namespaces:</p>
<pre class="brush: csharp;">
// C#

using Lesnikowski.Mail;
using Lesnikowski.Mail.Fluent;
using Lesnikowski.Mail.Appointments;
</pre>
<pre class="brush: vb;">
' VB.NET

Imports Lesnikowski.Mail
Imports Lesnikowski.Mail.Fluent
Imports Lesnikowski.Mail.Appointments
</pre>
<p>And now the code.</p>
<p>First we&#8217;ll create an appointment object add new event to it:</p>
<pre class="brush: csharp;">
Appointment appointment = new Appointment();
Event e = appointment.AddEvent();
</pre>
<p>Then we need to set <strong>start </strong>and <strong>end dates</strong>:</p>
<pre class="brush: csharp;">
e.Description = &quot;Status meeting description&quot;;
e.Summary = &quot;Status meeting summary&quot;;
e.Start = new DateTime(2010, 05, 10, 16, 00, 00);
e.End = new DateTime(2010, 05, 10, 17, 00, 00);
</pre>
<p>Now we&#8217;ll add all required and optional <strong>participants </strong> to it:</p>
<pre class="brush: csharp;">
e.SetOrganizer(new Person(&quot;Alice&quot;, &quot;alice@mail.com&quot;));

e.AddParticipant(new Participant(
	&quot;Bob&quot;, &quot;bob@mail.com&quot;, ParticipationRole.Required, true));
e.AddParticipant(new Participant(
	&quot;Tom&quot;, &quot;tom@mail.com&quot;, ParticipationRole.Optional, true));
e.AddParticipant(new Participant(
	&quot;Alice&quot;, &quot;alice@mail.com&quot;, ParticipationRole.Required, true));
</pre>
<p>We&#8217;ll add an <strong>alarm </strong>to the event (set 15 minutes before the event start):</p>
<pre class="brush: csharp;">
Alarm alarm = e.AddAlarm();
alarm.BeforeStart(TimeSpan.FromMinutes(15));
</pre>
<p>Finally we&#8217;ll create an email <strong>add the appointment</strong> to it and send it:</p>
<pre class="brush: csharp;">
Mail.Text(&quot;Status meeting at 4PM.&quot;)
	.Subject(&quot;Status meeting&quot;)
	.From(&quot;alice@mail.com&quot;)
    .To(&quot;bob@mail.com&quot;)
    .AddAppointment(appointment)
    .UsingNewSmtp()
    .WithCredentials(&quot;alice@mail.com&quot;, &quot;password&quot;)
	.Server(&quot;smtp.mail.com&quot;)
	.WithSSL()
	.Send();
</pre>
<p>The <strong>entire C# code</strong> looks as follows:</p>
<pre class="brush: csharp;">
Appointment appointment = new Appointment();

Event e = appointment.AddEvent();
e.Description = &quot;Status meeting description&quot;;
e.Summary = &quot;Status meeting summary&quot;;
e.Start = new DateTime(2010, 05, 10, 16, 00, 00);
e.End = new DateTime(2010, 05, 10, 17, 00, 00);

e.SetOrganizer(new Person(&quot;Alice&quot;, &quot;alice@mail.com&quot;));

e.AddParticipant(new Participant(
	&quot;Bob&quot;, &quot;bob@mail.com&quot;, ParticipationRole.Required, true));
e.AddParticipant(new Participant(
	&quot;Tom&quot;, &quot;tom@mail.com&quot;, ParticipationRole.Optional, true));
e.AddParticipant(new Participant(
	&quot;Alice&quot;, &quot;alice@mail.com&quot;, ParticipationRole.Required, true));

Alarm alarm = e.AddAlarm();
alarm.BeforeStart(TimeSpan.FromMinutes(15));

Mail.Text(&quot;Status meeting at 4PM.&quot;)
	.Subject(&quot;Status meeting&quot;)
	.From(&quot;alice@mail.com&quot;)
    .To(&quot;bob@mail.com&quot;)
    .AddAppointment(appointment)
    .UsingNewSmtp()
    .WithCredentials(&quot;alice@mail.com&quot;, &quot;password&quot;)
	.Server(&quot;smtp.mail.com&quot;)
	.WithSSL()
	.Send();
</pre>
<p>&#8230;and the VB.NET version:</p>
<pre class="brush: vb;">
Dim appointment As New Appointment()

Dim e As [Event] = appointment.AddEvent()
e.Description = &quot;Status meeting description&quot;
e.Summary = &quot;Status meeting summary&quot;
e.Start = New DateTime(2010, 5, 10, 16, 0, 0)
e.[End] = New DateTime(2010, 5, 10, 17, 0, 0)

e.SetOrganizer(New Person(&quot;Alice&quot;, &quot;alice@mail.com&quot;))

e.AddParticipant(New Participant( _
	&quot;Bob&quot;, &quot;bob@mail.com&quot;, ParticipationRole.Required, True))
e.AddParticipant(New Participant( _
	&quot;Tom&quot;, &quot;tom@mail.com&quot;, ParticipationRole.[Optional], True))
e.AddParticipant(New Participant( _
	&quot;Alice&quot;, &quot;alice@mail.com&quot;, ParticipationRole.Required, True))

Dim alarm As Alarm = e.AddAlarm()
alarm.BeforeStart(TimeSpan.FromMinutes(15))

Mail.Text(&quot;Status meeting at 4PM.&quot;) _
	.Subject(&quot;Status meeting&quot;) _
	.From(&quot;alice@mail.com&quot;) _
	.[To](&quot;bob@mail.com&quot;) _
	.AddAppointment(appointment) _
	.UsingNewSmtp() _
	.WithCredentials(&quot;alice@mail.com&quot;, &quot;password&quot;) _
	.Server(&quot;smtp.mail.com&quot;) _
	.WithSSL() _
	.Send()
</pre>
<p>You can download <a href="http://www.lesnikowski.com/mail/">Mail.dll .NET email component here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/send-icalendar-meeting-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Imap IDLE</title>
		<link>http://www.lesnikowski.com/blog/index.php/imap-idle/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=imap-idle</link>
		<comments>http://www.lesnikowski.com/blog/index.php/imap-idle/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 05:22:42 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IDLE]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=831</guid>
		<description><![CDATA[IDLE  is an IMAP feature described in RFC 2177 that allows a client to indicate to the server that it is ready to accept real-time notifications.
IMAP4 servers that support IDLE will include this programming string in the result of their CAPABILITY command. 
You can use Capability method to check server&#8217;s capability list

// C# code

using [...]]]></description>
			<content:encoded><![CDATA[<p><strong>IDLE </strong> is an IMAP feature described in RFC 2177 that allows a client to indicate to the server that it is ready to accept <strong>real-time notifications</strong>.</p>
<p>IMAP4 servers that support IDLE will include this programming string in the result of their CAPABILITY command. </p>
<p>You can use <em>Capability </em>method to check server&#8217;s capability list</p>
<pre class="brush: csharp;">
// C# code

using (Imap client = new Imap())
{
	client.ConnectSSL(&quot;imap.server.com&quot;);
	client.Capability().ForEach(Console.WriteLine);
	client.Close();
}
</pre>
<pre class="brush: vb;">
' VB.NET code

Using client As New Imap()
	client.ConnectSSL(&quot;imap.server.com&quot;)
	client.Capability().ForEach(Console.WriteLine)
	client.Close()
End Using
</pre>
<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2010/04/capabilities.png" alt="" title="capabilities" width="288" height="154" class="aligncenter size-full wp-image-833" /></p>
<p><a href="http://www.lesnikowski.com/mail/">Mail.dll IMAP client</a> supports IDLE command.</p>
<p>There are two important methods:</p>
<ul>
<li><em>Idle()</em> &#8211; starts accepting real-time notifications. The method hangs until a notification is received.</li>
<li><em>StopIdle()</em> &#8211; stops accepting real-time notifications.</li>
</ul>
<pre class="brush: csharp;">
// C# code

using (Imap client = new Imap())
{
    client.ConnectSSL(&quot;imap.server.com&quot;);
    client.Login(&quot;user@server.com&quot;, &quot;password&quot;);

    FolderStatus folderStatus = client.SelectInbox();
    Console.WriteLine(&quot;Total message count: {0}&quot;,
        folderStatus.MessageCount);

    while(true)
    {
        FolderStatus currentStatus = client.Idle();
        Console.WriteLine(&quot;Total message count: {0}&quot;,
                currentStatus.MessageCount);
        foreach(long uid in client.SearchFlag(Flag.Unseen))
        {
            IMail email = new MailBuilder().CreateFromEml(
                client.GetHeadersByUID(uid));
            Console.WriteLine(email.Subject);
        }
    }
    client.Close();
}
</pre>
<pre class="brush: vb;">
' VB.NET code

Using client As New Imap()
	client.ConnectSSL(&quot;imap.server.com&quot;)
	client.Login(&quot;user@server.com&quot;, &quot;password&quot;)

	Dim folderStatus As FolderStatus = client.SelectInbox()
	Console.WriteLine(&quot;Total message count: {0}&quot;,_
		folderStatus.MessageCount)

	While True
		Dim currentStatus As FolderStatus = client.Idle()
		Console.WriteLine(&quot;Total message count: {0}&quot;,_
			currentStatus.MessageCount)
		For Each uid As Long In client.SearchFlag(Flag.Unseen)
			Dim email As IMail = New MailBuilder()_
 				.CreateFromEml(client.GetHeadersByUID(uid))
			Console.WriteLine(email.Subject)
		Next
	End While
	client.Close()
End Using
</pre>
<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2010/04/idle.png" alt="" title="idle" width="300" height="143" class="aligncenter size-full wp-image-842" /></p>
<p>Now lets handle stop gracefully:</p>
<pre class="brush: csharp;">
// C# code

using (Imap client = new Imap())
{
    client.ConnectSSL(&quot;imap.server.com&quot;);
    client.Login(&quot;user@server.com&quot;, &quot;password&quot;);

    FolderStatus folderStatus = client.SelectInbox();
    Console.WriteLine(&quot;Total message count: {0}&quot;,
        currentStatus.MessageCount);

    bool stop = false;
    // We start a new thread to handle user input, &lt;enter&gt; = stop idle
    new Thread(() =&gt;
	{
		Console.ReadLine();
		client.StopIdle();
		stop = true;
	}).Start();

    while(stop == false)
    {
        FolderStatus currentStatus = client.Idle();
        if (stop == true)
            break;

        Console.WriteLine(&quot;Total message count: {0}&quot;,
            currentStatus.MessageCount);

        foreach(long uid in client.SearchFlag(Flag.Unseen))
        {
            IMail email = new MailBuilder().CreateFromEml(
                client.GetHeadersByUID(uid));
            Console.WriteLine(email.Subject);
        }
    }
    client.Close();
}
</pre>
<pre class="brush: vb;">
' VB.NET code

Using client As New Imap()
	client.ConnectSSL(&quot;imap.server.com&quot;)
	client.Login(&quot;user@server.com&quot;, &quot;password&quot;)

	Dim folderStatus As FolderStatus = client.SelectInbox()
	Console.WriteLine(&quot;Total message count: {0}&quot;,_
		currentStatus.MessageCount)

	Dim [stop] As Boolean = False
	' We start a new thread to handle user input, &lt;enter&gt; = stop idle
	New Thread(Function() Do
		Console.ReadLine()
		client.StopIdle()
		[stop] = True
	End Function).Start()

	While [stop] = False
		Dim currentStatus As FolderStatus = client.Idle()
		If [stop] = True Then
			Exit While
		End If

		Console.WriteLine(&quot;Total message count: {0}&quot;,_
			currentStatus.MessageCount)

		For Each uid As Long In client.SearchFlag(Flag.Unseen)
			Dim email As IMail = New MailBuilder()_
				.CreateFromEml(client.GetHeadersByUID(uid))
			Console.WriteLine(email.Subject)
		Next
	End While
	client.Close()
End Using
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/imap-idle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Mail.dll tutorial video</title>
		<link>http://www.lesnikowski.com/blog/index.php/new-mail-dll-tutorial-video/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=new-mail-dll-tutorial-video</link>
		<comments>http://www.lesnikowski.com/blog/index.php/new-mail-dll-tutorial-video/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 11:29:05 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[GMail]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[Mail.dll]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=799</guid>
		<description><![CDATA[New Mail.dll tutorial video is out. You can watch it here: 
.
]]></description>
			<content:encoded><![CDATA[<p>New <strong>Mail.dll tutorial video</strong> is out. You can watch it here: </p>
<p><a href="http://www.lesnikowski.com/mail/tutorial/tutorial.aspx"><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2010/04/MailVideoThumb.jpg" alt="Mail.dll tutorial video" width="64" height="51" class="alignnone size-full wp-image-801" /></a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/new-mail-dll-tutorial-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delete email permanently in GMail</title>
		<link>http://www.lesnikowski.com/blog/index.php/delete-email-permanently-in-gmail/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=delete-email-permanently-in-gmail</link>
		<comments>http://www.lesnikowski.com/blog/index.php/delete-email-permanently-in-gmail/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 19:00:37 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[GMail]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[Mail.dll]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=575</guid>
		<description><![CDATA[If you delete a message from your Inbox or one of your custom folders, it will still appear in [Gmail]/All Mail.
Here&#8217;s why: in most folders, deleting a message simply removes that folder&#8217;s label from the message, including the label identifying the message as being in your Inbox.
[Gmail]/All Mail shows all of your messages, whether or [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2009/11/gmail.png" alt="" title="gmail" width="131" height="61" class="alignleft size-full wp-image-271" />If you delete a message from your Inbox or one of your custom folders, <strong>it will still appear in [Gmail]/All Mail</strong>.</p>
<p>Here&#8217;s why: in most folders, <strong>deleting a message simply removes that folder&#8217;s label from the message</strong>, including the label identifying the message as being in your Inbox.</p>
<p>[Gmail]/All Mail shows all of your messages, whether or not they have labels attached to them.</p>
<p>If you want to<strong> permanently delete a message</strong> from all folders:</p>
<ol>
<li> <strong>Move it to the [Gmail]/Trash</strong> folder.</li>
<li> <strong>Delete it</strong> from the [Gmail]/Trash folder.</li>
</ol>
<p>All emails in [Gmail]/Spam and [Gmail]/Trash are deleted after 30 days.<br />
If you delete a message from [Gmail]/Spam or [Gmail]/Trash, it will be deleted permanently.</p>
<p>Here&#8217;s how this looks like using <a href="http://www.lesnikowski.com/mail/">Mail.dll IMAP client</a>:</p>
<pre class="brush: csharp;">
// C# version:

using(Imap imap = new Imap())
{
	imap.Connect(&quot;imap.gmail.com&quot;);
	imap.Login(&quot;user&quot;, &quot;password&quot;);

	// Find all emails we want to delete
	imap.SelectInbox();
	List&lt;long&gt; uids = imap.Search(
		Expression.Subject(&quot;email to delete&quot;));

	// Delete each email permanently
	foreach (long uid in uids)
	{
		// Move to Trash
		long uidInTrash = (long)imap.MoveByUID(uid, &quot;[Gmail]/Trash&quot;);

		// Delete from Trash
		imap.Select(&quot;[Gmail]/Trash&quot;);
		imap.DeleteMessageByUID(uidInTrash);
	}
	imap.Close(true);
}
</pre>
<pre class="brush: vb;">
' VB.NET version:

Using imap As New Imap()
	imap.Connect(&quot;imap.gmail.com&quot;)
	imap.Login(&quot;user@gmail.com&quot;, &quot;password&quot;)

	' Find all emails we want to delete
	imap.SelectInbox()
	Dim uids As List(Of Long) = imap.Search(_
		Expression.Subject(&quot;email to delete&quot;))

	' Delete each email permanently
	For Each uid As Long In uids
		' Move to Trash
		Dim uidInTrash As Long = imap.MoveByUID(uid, &quot;[Gmail]/Trash&quot;)

		' Delete from Trash
		imap.[Select](&quot;[Gmail]/Trash&quot;)
		imap.DeleteMessageByUID(uidInTrash)
	Next
	imap.Close(True)
End Using
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/delete-email-permanently-in-gmail/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
