<?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; SMTP</title>
	<atom:link href="http://www.lesnikowski.com/blog/tag/smtp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lesnikowski.com/blog</link>
	<description>EMAIL IMAP POP3 SMTP FTP FTPS barcode components blog</description>
	<lastBuildDate>Sun, 05 Feb 2012 14:10:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Send iCalendar meeting requests for different timezone</title>
		<link>http://www.lesnikowski.com/blog/send-icalendar-meeting-requests-for-different-timezone/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=send-icalendar-meeting-requests-for-different-timezone</link>
		<comments>http://www.lesnikowski.com/blog/send-icalendar-meeting-requests-for-different-timezone/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 14:18:57 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[iCalendar]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[SMTP]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=1842</guid>
		<description><![CDATA[Usually you define time of an event in relation to UTC time zone. If you need to define event on 9:00 o&#8217;clock in Alaska you simply need to subtract 9 hours from event time to get the event time in UTC (18:00:00). 18 &#8211; 9 = 9. It all works great in December (Alaska is [...]]]></description>
			<content:encoded><![CDATA[<p>Usually you define time of an event in relation to UTC time zone.</p>
<p>If you need to define event on 9:00 o&#8217;clock in Alaska you simply need<br />
to subtract 9 hours from event time to get the event time in UTC<br />
(18:00:00). 18 &#8211; 9 = 9.</p>
<p>It all works great in December (Alaska is UTC-9), but in May, daylight<br />
saving time is in effect in Alaska (Alaska is UTC-8 then).</p>
<p>If the event is recurring, in May, event is going to be held on 10:00<br />
Alaska time (18 &#8211; 8 = 10). Which is most likely not what you want.</p>
<p>As the time zones in different parts of world change way to often to reflect these changes in Mail.dll,<br />
you&#8217;ll need to specify the time zone when creating new event (including the daylight savings time).</p>
<p>Here&#8217;s the sample:</p>
<pre class="brush: csharp;">
// C#
using Fluent = Lesnikowski.Mail.Fluent;
using Lesnikowski.Client;
using Lesnikowski.Mail;
using Lesnikowski.Mail.Appointments;

Appointment appointment = new Appointment();

// Create time zone
VTimeZone alaska = appointment.AddTimeZone();
alaska.TimeZoneId = &quot;America/Anchorage&quot;;

// Define standard time offset
var standardRecurring = new RecurringRule();
standardRecurring.Frequency = Frequency.Yearly;
standardRecurring.ByDay.Add(Weekday.Sunday);
standardRecurring.ByMonths.Add(11);

var standard = new StandardOffset
{
    Name = &quot;AKST&quot;,
    Start = new DateTime(1970, 11, 01, 02, 00, 00),
    OffsetFrom = TimeSpan.FromHours(-8),
    OffsetTo = TimeSpan.FromHours(-9),
    RecurringRule = standardRecurring
};

// Define daylight time offset
var daylightRecurring = new RecurringRule();
daylightRecurring.Frequency = Frequency.Yearly;
daylightRecurring.ByDay.Add(new Weekday(2, Weekday.Sunday));
daylightRecurring.ByMonths.Add(3);

var daylight = new DaylightOffset
{
    Name = &quot;AKDT&quot;,
    Start = new DateTime(1970, 03, 08, 02, 00, 00),
    OffsetFrom = TimeSpan.FromHours(-9),
    OffsetTo = TimeSpan.FromHours(-8),
    RecurringRule = daylightRecurring
};

alaska.Standard.Add(standard);
alaska.Daylight.Add(daylight);

// Define event
Event e = appointment.AddEvent();
e.Start = new DateTime(2007, 08, 17, 12, 00, 00);
e.End = new DateTime(2007, 08, 17, 12, 30, 00);
e.Summary = &quot;At noon in Alaska&quot;;
e.InTimeZone(alaska);

e.SetOrganizer(new Person(&quot;Alice&quot;, &quot;alice@example.org&quot;));

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

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

IMail email = Fluent.Mail
    .Text(&quot;Status meeting at noon in Alaska.&quot;)
    .Subject(&quot;Status meeting&quot;)
    .From(&quot;alice@example.org&quot;)
    .To(&quot;bob@example.org&quot;)
    .To(&quot;tom@example.org&quot;)
    .AddAppointment(appointment)
    .Create();

using (Smtp smtp = new Smtp())
{
    smtp.Connect(&quot;smtp.example.org&quot;); // or ConnectSSL
    smtp.Login(&quot;user&quot;, &quot;password&quot;);
    smtp.SendMessage(email);
    smtp.Close();
}
</pre>
<pre class="brush: vb;">
' VB.NET
Imports Fluent = Lesnikowski.Mail.Fluent
Imports Lesnikowski.Client
Imports Lesnikowski.Mail
Imports Lesnikowski.Mail.Appointments

Dim appointment As New Appointment()

' Create time zone
Dim alaska As VTimeZone = appointment.AddTimeZone()
alaska.TimeZoneId = &quot;America/Anchorage&quot;

' Define standard time offset
Dim standardRecurring = New RecurringRule()
standardRecurring.Frequency = Frequency.Yearly
standardRecurring.ByDay.Add(Weekday.Sunday)
standardRecurring.ByMonths.Add(11)

Dim standard = New StandardOffset() With { _
	.Name = &quot;AKST&quot;, _
	.Start = New DateTime(1970, 11, 1, 2, 0, 0), _
	.OffsetFrom = TimeSpan.FromHours(-8), _
	.OffsetTo = TimeSpan.FromHours(-9), _
	.RecurringRule = standardRecurring _
}

' Define daylight time offset
Dim daylightRecurring = New RecurringRule()
daylightRecurring.Frequency = Frequency.Yearly
daylightRecurring.ByDay.Add(New Weekday(2, Weekday.Sunday))
daylightRecurring.ByMonths.Add(3)

Dim daylight = New DaylightOffset() With { _
	.Name = &quot;AKDT&quot;, _
	.Start = New DateTime(1970, 3, 8, 2, 0, 0), _
	.OffsetFrom = TimeSpan.FromHours(-9), _
	.OffsetTo = TimeSpan.FromHours(-8), _
	.RecurringRule = daylightRecurring _
}

alaska.Standard.Add(standard)
alaska.Daylight.Add(daylight)

' Define event
Dim e As [Event] = appointment.AddEvent()
e.Start = New DateTime(2007, 8, 17, 12, 0, 0)
e.[End] = New DateTime(2007, 8, 17, 12, 30, 0)
e.Summary = &quot;At noon in Alaska&quot;
e.InTimeZone(alaska)

e.SetOrganizer(New Person(&quot;Alice&quot;, &quot;alice@example.org&quot;))

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

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

Dim email As IMail = Fluent.Mail _
	.Text(&quot;Status meeting at noon in Alaska.&quot;) _
	.Subject(&quot;Status meeting&quot;) _
	.From(&quot;alice@example.org&quot;) _
	.[To](&quot;bob@example.org&quot;) _
	.[To](&quot;tom@example.org&quot;) _
	.AddAppointment(appointment) _
	.Create()

Using smtp As New Smtp()
	smtp.Connect(&quot;smtp.example.org&quot;) 	' or ConnectSSL
	smtp.Login(&quot;user&quot;, &quot;password&quot;)
	smtp.SendMessage(email)
	smtp.Close()
End Using
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/send-icalendar-meeting-requests-for-different-timezone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reply to an email</title>
		<link>http://www.lesnikowski.com/blog/reply-to-email/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=reply-to-email</link>
		<comments>http://www.lesnikowski.com/blog/reply-to-email/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 09:53:34 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=2188</guid>
		<description><![CDATA[You can use Mail.dll to reply to an HTML or plain-text email. ReplyBuilder class allows you to specify custom HTML and plain-text templates for the reply. Mail.dll will parse HTML extract body part, and build-in template engine will do the rest. The next great thing is that plain-text version of the email is generated automatically. [...]]]></description>
			<content:encoded><![CDATA[<p>You can use Mail.dll to reply to an HTML or plain-text email.</p>
<p>ReplyBuilder class allows you to specify custom HTML and plain-text templates for the reply. Mail.dll will parse HTML extract body part, and build-in template engine will do the rest.</p>
<p>The next great thing is that plain-text version of the email is generated automatically.</p>
<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2011/12/reply.png" alt="" title="reply" width="429" height="388" class="aligncenter size-full wp-image-2197" /></p>
<pre class="brush: csharp;">
// C#

IMail original = ...;

ReplyBuilder replyBuilder = original.Reply();
// You can specify your own custom template:
replyBuilder.HtmlReplyTemplate =
    &quot;[Html]&quot; +
    &quot;&lt;br /&gt;&lt;br /&gt;&quot; +
    &quot;On [Original.Date] [Original.Sender.Name] wrote:&quot; +
    &quot;&lt;blockquote &quot; +
        &quot;style='margin-left: 1em; &quot; +
        &quot;padding-left: 1em; &quot; +
        &quot;border-left: 1px #ccc solid;'&gt;&quot; +
    &quot;[QuoteHtml]&quot; +
    &quot;&lt;/blockquote&gt;&quot;;

replyBuilder.Html =
    &quot;Alice, &lt;br/&gt;&lt;br/&gt;thanks for your email.&quot;;

MailBuilder builder = replyBuilder.ReplyToAll(
    new MailBox(&quot;bob@example.org&quot;, &quot;Bob&quot;));

// You can add attachments to your reply
//builder.AddAttachment(&quot;report.csv&quot;);

IMail reply = builder.Create();

using (Smtp smtp = new Smtp())
{
    smtp.Connect(&quot;smtp.example.com&quot;); // or ConnectSSL
    smtp.Login(&quot;user&quot;, &quot;password&quot;);
    smtp.SendMessage(reply);
    smtp.Close();
}
</pre>
<pre class="brush: vb;">
' VB.NET

Dim original As IMail = ...

Dim replyBuilder As ReplyBuilder = original.Reply()

' You can specify your own custom template:
replyBuilder.HtmlReplyTemplate = _
    &quot;[Html]&quot; + _
    &quot;&lt;br /&gt;&lt;br /&gt;&quot; + _
    &quot;On [Original.Date] [Original.Sender.Name] wrote:&quot; + _
    &quot;&lt;blockquote &quot; + _
        &quot;style='margin-left: 1em; &quot; + _
        &quot;padding-left: 1em; &quot; + _
        &quot;border-left: 1px #ccc solid;'&gt;&quot; + _
    &quot;[QuoteHtml]&quot; + _
    &quot;&lt;/blockquote&gt;&quot;

replyBuilder.Html = _
    &quot;Alice, &lt;br/&gt;&lt;br/&gt;thanks for your email.&quot;

Dim builder As MailBuilder = replyBuilder.ReplyToAll( _
    New MailBox(&quot;bob@example.org&quot;, &quot;Bob&quot;))

' You can add attachments to your reply
'builder.AddAttachment(&quot;report.csv&quot;)

Dim reply As IMail = builder.Create()

Using smtp As New Smtp()
	smtp.Connect(&quot;smtp.example.com&quot;)
	smtp.Login(&quot;user&quot;, &quot;password&quot;) ' or ConnectSSL
	smtp.SendMessage(reply)
	smtp.Close()
End Using
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/reply-to-email/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Get supported authentication methods (IMAP, POP3, SMTP)</title>
		<link>http://www.lesnikowski.com/blog/get-supported-authentication-methods-imap-pop3-smtp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=get-supported-authentication-methods-imap-pop3-smtp</link>
		<comments>http://www.lesnikowski.com/blog/get-supported-authentication-methods-imap-pop3-smtp/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 15:13:53 +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=2000</guid>
		<description><![CDATA[You can use SupportedAuthenticationMethodsto retrieve all authentication methods supported by the server: // C# using (Imap client = new Imap()) { client.ConnectSSL(&#34;imap.example.org&#34;); client.UseBestLogin(&#34;user&#34;, &#34;password&#34;); Console.WriteLine(&#34;Supported methods:&#34;); foreach (var method in client.SupportedAuthenticationMethods()) { Console.WriteLine(method.Name); } Console.WriteLine(&#34;Supports CramMD5:&#34;); bool supportsCramMD5 = client.SupportedAuthenticationMethods() .Contains(ImapAuthenticationMethod.CramMD5); Console.WriteLine(supportsCramMD5); client.Close(); } ' VB.NET Using client As New Imap() client.ConnectSSL(&#34;imap.example.org&#34;) client.UseBestLogin(&#34;user&#34;, &#34;password&#34;) Console.WriteLine(&#34;Supported [...]]]></description>
			<content:encoded><![CDATA[<p>You can use <em>SupportedAuthenticationMethods</em>to retrieve all authentication methods supported by the server:</p>
<pre class="brush: csharp;">
// C#

using (Imap client = new Imap())
{
    client.ConnectSSL(&quot;imap.example.org&quot;);
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;);

    Console.WriteLine(&quot;Supported methods:&quot;);

    foreach (var method in client.SupportedAuthenticationMethods())
    {
        Console.WriteLine(method.Name);
    }

    Console.WriteLine(&quot;Supports CramMD5:&quot;);

    bool supportsCramMD5 = client.SupportedAuthenticationMethods()
        .Contains(ImapAuthenticationMethod.CramMD5);

    Console.WriteLine(supportsCramMD5);

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

Using client As New Imap()
    client.ConnectSSL(&quot;imap.example.org&quot;)
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;)

    Console.WriteLine(&quot;Supported methods:&quot;)

    For Each method As ImapAuthenticationMethod In client.SupportedAuthenticationMethods()
	    Console.WriteLine(method.Name)
    Next

    Console.WriteLine(&quot;Supports CramMD5:&quot;)

    Dim supportsCramMD5 As Boolean = client.SupportedAuthenticationMethods() _
        .Contains(ImapAuthenticationMethod.CramMD5)

    Console.WriteLine(supportsCramMD5)

    client.Close()
End Using
</pre>
<p>For example Gmail produces following output:</p>
<pre class="brush: plain;">
Supported method s:
IMAP4rev1
UNSELECT
IDLE
NAMESPACE
QUOTA
ID
XLIST
CHILDREN
X-GM-EXT-1
UIDPLUS
COMPRESS

Supports CramMD5:
False
</pre>
<p>We take great care for the API to look similar for all protocols (IMAP, POP3, SMTP).</p>
<p>Here&#8217;s the<strong> sample for POP3</strong>:</p>
<pre class="brush: csharp;">
// C#

using (Pop3 client = new Pop3())
{
    client.ConnectSSL(&quot;pop3.example.org&quot;);
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;);

    Console.WriteLine(&quot;Supported methods:&quot;);

    foreach (var method in client.SupportedAuthenticationMethods())
    {
        Console.WriteLine(method.Name);
    }

    Console.WriteLine(&quot;Supports CramMD5:&quot;);

    bool supportsCramMD5 = client.SupportedAuthenticationMethods()
        .Contains(Pop3AuthenticationMethod.CramMD5);

    Console.WriteLine(supportsCramMD5);

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

Using client As New Pop3()
    client.ConnectSSL(&quot;pop3.example.org&quot;)
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;)

    Console.WriteLine(&quot;Supported methods:&quot;)

    For Each method As Pop3AuthenticationMethod In client.SupportedAuthenticationMethods()
	    Console.WriteLine(method.Name)
    Next

    Console.WriteLine(&quot;Supports CramMD5:&quot;)

    Dim supportsCramMD5 As Boolean = client.SupportedAuthenticationMethods() _
        .Contains(Pop3AuthenticationMethod.CramMD5)

    Console.WriteLine(supportsCramMD5)

    client.Close()
End Using
</pre>
<p>Here&#8217;s the<strong> sample for SMTP</strong>:</p>
<pre class="brush: csharp;">
// C#

using (Smtpclient = new Smtp())
{
    client.Connect(&quot;smtp.example.org&quot;);
    client.UseBestLogin(&quot;smtp&quot;, &quot;password&quot;);

    Console.WriteLine(&quot;Supported methods:&quot;);

    foreach (var method in client.SupportedAuthenticationMethods())
    {
        Console.WriteLine(method.Name);
    }

    Console.WriteLine(&quot;Supports CramMD5:&quot;);

    bool supportsCramMD5 = client.SupportedAuthenticationMethods()
        .Contains(SmtpAuthenticationMethod.CramMD5);

    Console.WriteLine(supportsCramMD5);

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

Using client As New Smtp()
    client.Connect(&quot;smtp.example.org&quot;)
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;)

    Console.WriteLine(&quot;Supported methods:&quot;)

    For Each method As SmtpAuthenticationMethod In client.SupportedAuthenticationMethods()
	    Console.WriteLine(method.Name)
    Next

    Console.WriteLine(&quot;Supports CramMD5:&quot;)

    Dim supportsCramMD5 As Boolean = client.SupportedAuthenticationMethods() _
        .Contains(SmtpAuthenticationMethod.CramMD5)

    Console.WriteLine(supportsCramMD5)

    client.Close()
End Using
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/get-supported-authentication-methods-imap-pop3-smtp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get supported server extensions (IMAP, POP3, SMTP)</title>
		<link>http://www.lesnikowski.com/blog/get-supported-server-extensions-imap-pop3-smtp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=get-supported-server-extensions-imap-pop3-smtp</link>
		<comments>http://www.lesnikowski.com/blog/get-supported-server-extensions-imap-pop3-smtp/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 12:46:12 +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>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=1992</guid>
		<description><![CDATA[You can use SupportedExtensionsmethod to retrieve all protocol extensions supported by the server: // C# using (Imap client = new Imap()) { client.ConnectSSL(&#34;imap.example.org&#34;); client.UseBestLogin(&#34;user&#34;, &#34;password&#34;); Console.WriteLine(&#34;Supported extensions:&#34;); foreach (ImapExtension extension in client.SupportedExtensions()) { Console.WriteLine(extension.Name); } Console.WriteLine(&#34;Supports IDLE:&#34;); bool supportsIdle = client.SupportedExtensions() .Contains(ImapExtension.Idle); Console.WriteLine(supportsIdle); client.Close(); } ' VB.NET Using client As New Imap() client.ConnectSSL(&#34;imap.example.org&#34;) client.UseBestLogin(&#34;user&#34;, &#34;password&#34;) [...]]]></description>
			<content:encoded><![CDATA[<p>You can use <em>SupportedExtensionsmethod </em>to retrieve all protocol extensions supported by the server:</p>
<pre class="brush: csharp;">
// C#

using (Imap client = new Imap())
{
    client.ConnectSSL(&quot;imap.example.org&quot;);
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;);

    Console.WriteLine(&quot;Supported extensions:&quot;);

    foreach (ImapExtension extension in client.SupportedExtensions())
    {
        Console.WriteLine(extension.Name);
    }

    Console.WriteLine(&quot;Supports IDLE:&quot;);

    bool supportsIdle = client.SupportedExtensions()
        .Contains(ImapExtension.Idle);

    Console.WriteLine(supportsIdle);

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

Using client As New Imap()
    client.ConnectSSL(&quot;imap.example.org&quot;)
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;)

    Console.WriteLine(&quot;Supported extensions:&quot;)

    For Each extension As ImapExtension In client.SupportedExtensions()
	    Console.WriteLine(extension.Name)
    Next

    Console.WriteLine(&quot;Supports IDLE:&quot;)

    Dim supportsIdle As Boolean = client.SupportedExtensions() _
        .Contains(ImapExtension.Idle)

    Console.WriteLine(supportsIdle)

    client.Close()
End Using
</pre>
<p>For example Gmail produces following output:</p>
<pre class="brush: plain;">
Supported extensions:
IMAP4rev1
UNSELECT
IDLE
NAMESPACE
QUOTA
ID
XLIST
CHILDREN
X-GM-EXT-1
UIDPLUS
COMPRESS

Supports IDLE:
True
</pre>
<p>We take great care for the API to look similar for all protocols (IMAP, POP3, SMTP).</p>
<p>Here&#8217;s the<strong> sample for POP3</strong>:</p>
<pre class="brush: csharp;">
// C#

using (Pop3 client = new Pop3())
{
    client.ConnectSSL(&quot;pop3.example.org&quot;);
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;);

    Console.WriteLine(&quot;Supported extensions:&quot;);

    foreach (Pop3Extension extension in client.SupportedExtensions())
    {
        Console.WriteLine(extension.Name);
    }

    Console.WriteLine(&quot;Supports TOP:&quot;);

    bool supportsTop= client.SupportedExtensions()
        .Contains(Pop3Extension.Top);

    Console.WriteLine(supportsTop);

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

Using client As New Pop3()
    client.ConnectSSL(&quot;pop3.example.org&quot;)
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;)

    Console.WriteLine(&quot;Supported extensions:&quot;)

    For Each extension As Pop3Extension In client.SupportedExtensions()
	    Console.WriteLine(extension.Name)
    Next

    Console.WriteLine(&quot;Supports TOP:&quot;)

    Dim supportsTop As Boolean = client.SupportedExtensions() _
        .Contains(Pop3Extension.Top)

    Console.WriteLine(supportsTop)

    client.Close()
End Using
</pre>
<p>Here&#8217;s the<strong> sample for SMTP</strong>:</p>
<pre class="brush: csharp;">
// C#

using (Smtpclient = new Smtp())
{
    client.Connect(&quot;smtp.example.org&quot;);
    client.UseBestLogin(&quot;smtp&quot;, &quot;password&quot;);

    Console.WriteLine(&quot;Supported extensions:&quot;);

    foreach (SmtpExtension  extension in client.SupportedExtensions())
    {
        Console.WriteLine(extension.Name);
    }

    Console.WriteLine(&quot;Supports STARTTLS:&quot;);

    bool supportsStartTLS = client.SupportedExtensions()
        .Contains(SmtpExtension.StartTLS);

    Console.WriteLine(supportsStartTLS);

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

Using client As New Smtp()
    client.Connect(&quot;smtp.example.org&quot;)
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;)

    Console.WriteLine(&quot;Supported extensions:&quot;)

    For Each extension As SmtpExtension In client.SupportedExtensions()
	    Console.WriteLine(extension.Name)
    Next

    Console.WriteLine(&quot;Supports STARTTLS:&quot;)

    Dim supportsStartTLS As Boolean = client.SupportedExtensions() _
        .Contains(SmtpExtension.StartTLS)

    Console.WriteLine(supportsStartTLS)

    client.Close()
End Using
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/get-supported-server-extensions-imap-pop3-smtp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Send encrypted email using S/MIME</title>
		<link>http://www.lesnikowski.com/blog/send-encrypted-email-using-smime/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=send-encrypted-email-using-smime</link>
		<comments>http://www.lesnikowski.com/blog/send-encrypted-email-using-smime/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 13:00:22 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[SMIME]]></category>
		<category><![CDATA[SMTP]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=1693</guid>
		<description><![CDATA[Sending encrypted and signed S/MIME messages has never been easier: // C# version IMail email = Mail .Html(&#34;&#60;html&#62;&#60;body&#62;Encrypted and signed&#60;/body&#62;&#60;/html&#62;&#34;) .Subject(&#34;Encrypted and signed&#34;) .From(new MailBox(&#34;email@in-the-certificate.com&#34;, &#34;Alice&#34;)) .To(new MailBox(&#34;bob@mail.com&#34;, &#34;Bob&#34;)) .AddAttachment(@&#34;c:report_2010.pdf&#34;) .SignWith(new X509Certificate2(&#34;SignCertificate.pfx&#34;, &#34;&#34;)) .EncryptWith(new X509Certificate2(&#34;EncryptCertificate.pfx&#34;, &#34;&#34;)) .EncryptWith(new X509Certificate2(&#34;BobsCertificate.pfx&#34;, &#34;&#34;)) .Create(); using (Smtp client = new Smtp()) { client.ConnectSSL(&#34;smtp.example.com&#34;); client.Login(&#34;user&#34;, &#34;password&#34;); client.SendMessage(email); client.Close(); } ' VB.NET [...]]]></description>
			<content:encoded><![CDATA[<p>Sending encrypted and signed S/MIME messages has never been easier:</p>
<pre class="brush: csharp;">
// C# version

IMail email = Mail
    .Html(&quot;&lt;html&gt;&lt;body&gt;Encrypted and signed&lt;/body&gt;&lt;/html&gt;&quot;)
    .Subject(&quot;Encrypted and signed&quot;)
    .From(new MailBox(&quot;email@in-the-certificate.com&quot;, &quot;Alice&quot;))
    .To(new MailBox(&quot;bob@mail.com&quot;, &quot;Bob&quot;))
    .AddAttachment(@&quot;c:report_2010.pdf&quot;)
    .SignWith(new X509Certificate2(&quot;SignCertificate.pfx&quot;, &quot;&quot;))
    .EncryptWith(new X509Certificate2(&quot;EncryptCertificate.pfx&quot;, &quot;&quot;))
    .EncryptWith(new X509Certificate2(&quot;BobsCertificate.pfx&quot;, &quot;&quot;))
    .Create();

using (Smtp client = new Smtp())
{
    client.ConnectSSL(&quot;smtp.example.com&quot;);
    client.Login(&quot;user&quot;, &quot;password&quot;);
    client.SendMessage(email);
    client.Close();
}
</pre>
<pre class="brush: vb;">
' VB.NET version

Dim email As IMail = Mail _
	.Html(&quot;&lt;html&gt;&lt;body&gt;Encrypted and signed&lt;/body&gt;&lt;/html&gt;&quot;) _
	.Subject(&quot;Encrypted and signed&quot;) _
	.From(New MailBox(&quot;email@in-the-certificate.com&quot;, &quot;Alice&quot;)) _
	.To(New MailBox(&quot;bob@mail.com&quot;, &quot;Bob&quot;)) _
	.AddAttachment(&quot;c:report_2010.pdf&quot;) _
	.SignWith(New X509Certificate2(&quot;SignCertificate.pfx&quot;, &quot;&quot;)) _
	.EncryptWith(New X509Certificate2(&quot;EncryptCertificate.pfx&quot;, &quot;&quot;)) _
	.EncryptWith(New X509Certificate2(&quot;BobsCertificate.pfx&quot;, &quot;&quot;)) _
	.Create()

Using client As New Smtp()
	client.ConnectSSL(&quot;smtp.example.com&quot;)
	client.Login(&quot;user&quot;, &quot;password&quot;)
	client.SendMessage(email)
	client.Close()
End Using
</pre>
<p>Remember to <strong>encrypt your emails with both sender&#8217;s and receiver&#8217;s certificates</strong>.<br />
This way both parties are able to decrypt such emails.</p>
<p>Common errors you may encounter:</p>
<ul>
<li>Please use the <strong>PersistKeySet </strong> flag when loading from file (new X509Certificate2(_certificatePath, &#8220;&#8221;, X509KeyStorageFlags.PersistKeySet);) and adding to store
</li>
<li><strong>&#8220;Bad key&#8221;</strong> exception message means that certificate was not for key exchange &#8211; makecert needs an extra parameter to create certificate that can be used for symmetric algorithm key exchange: -sky exchange.
</li>
<li><strong>&#8220;the enveloped data-message does not contain the specified recipient&#8221;</strong> means that certificate with the private key is not deployed into the current account/local machine personal store, or not in the certificates list
</li>
</ul>
<p>You can use following commands in VisualStudio Command Prompt to create test certificate:<br />
<code><br />
makecert.exe -pe -r -sv Test_Keys.pvk -n "CN=John Doe,E=email@in-the-certificate.com" -sky exchange Test.cer</p>
<p>pvk2pfx.exe -pvk Test_Keys.pvk -spc Test.cer -pfx Test.pfx<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/send-encrypted-email-using-smime/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I have problems issuing IMAP, POP3 or SMTP command</title>
		<link>http://www.lesnikowski.com/blog/i-have-problems-issuing-imap-pop3-smtp-command/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=i-have-problems-issuing-imap-pop3-smtp-command</link>
		<comments>http://www.lesnikowski.com/blog/i-have-problems-issuing-imap-pop3-smtp-command/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 14:51:44 +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=1734</guid>
		<description><![CDATA[Mail.dll is a rock solid product, however most email servers don&#8217;t follow rigorously the RFC specifications. In the following few steps we&#8217;ll help you gather the information we need to make Mail.dll clients better. If you are having the problems parsing a single message please go here 1. First please check if you have the [...]]]></description>
			<content:encoded><![CDATA[<p>Mail.dll is a rock solid product, however most email servers don&#8217;t follow rigorously the RFC specifications. In the following few steps we&#8217;ll help you gather the information we need to make Mail.dll clients better.</p>
<p>If you are having the problems parsing a single message please <a href="http://www.lesnikowski.com/blog/i-have-problems-parsing-the-message">go here</a></p>
<p>1.<br />
First please check if you have the latest version installed.</p>
<p>2.<br />
Please <strong>identify the command/set of commands</strong> that cause problems.</p>
<p>3.<br />
<strong>Enable logging</strong> for Mail.dll clients:</p>
<pre class="brush: csharp;">
// C# version:

Log.Enabled = true;
</pre>
<pre class="brush: vb;">
// VB.NET version:

Log.Enabled = True
</pre>
<p>You can observe standard Visual Studio trace output or add a custom listener to <em>Trace.Listeners</em> collection.</p>
<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2010/11/Mail_Log.png" alt="" title="Mail.dll Log" width="602" height="582" class="aligncenter size-full wp-image-1479" /></p>
<p>You can also enable logging using App.config file:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;configuration&gt;
    &lt;system.diagnostics&gt;
      &lt;switches&gt;
        &lt;add name=&quot;Mail.dll&quot; value=&quot;True&quot; /&gt;
      &lt;/switches&gt;
    &lt;/system.diagnostics&gt;
&lt;/configuration&gt;
</pre>
<p>You can create your custom TraceListener that writes log to file:</p>
<pre class="brush: csharp;">
// C# version:

internal class MyListener : TextWriterTraceListener
{
    public MyListener(string fileName)
        : base(fileName)
    {
    }

    public override void Write(string message, string category)
    {
        if (category == &quot;Mail.dll&quot;)
            base.Write(message, category);
    }

    public override void WriteLine(string message, string category)
    {
        if (category == &quot;Mail.dll&quot;)
            base.WriteLine(message, category);
    }
}
</pre>
<pre class="brush: vb;">
' VB.NET version

Friend Class MyListener
	Inherits TextWriterTraceListener
	Public Sub New(fileName As String)
		MyBase.New(fileName)
	End Sub

	Public Overrides Sub Write(message As String, category As String)
		If category = &quot;Mail.dll&quot; Then
			MyBase.Write(message, category)
		End If
	End Sub

	Public Overrides Sub WriteLine(message As String, category As String)
		If category = &quot;Mail.dll&quot; Then
			MyBase.WriteLine(message, category)
		End If
	End Sub
End Class
</pre>
<p>&#8230;then add it to Listeners collection:</p>
<pre class="brush: csharp;">
// C# version:

Log.Enabled = true;
Trace.Listeners.Add(new MyListener(@&quot;c:mail_log.txt&quot;));
Trace.AutoFlush = true;
</pre>
<pre class="brush: vb;">
// VB.NET version:

Log.Enabled = True
Trace.Listeners.Add(New MyListener(&quot;c:mail_log.txt&quot;))
Trace.AutoFlush = True
</pre>
<p>4.<br />
Perform the operations that cause the problems, and save the log to file.<br />
You can remove username and password, but please do not modify the file extensively. If you do, it may be impossible to reproduce the issue.<br />
In particular do not change new line format nor encoding.</p>
<p>5.<br />
Please answer following questions:</p>
<ul>
<li>What <strong>exception </strong>are you getting?</li>
<li>What is the exception <strong>stack trace</strong>?</li>
<li>What is the exception <strong>message</strong>?</li>
<li>What result you expect?</li>
<li>What result are you getting?</li>
<li>Which .NET Framework version are you using?</li>
<li>Is it console, windows forms, windows service or web application?</li>
<li>If it is possible please attach the source code you are using</li>
</ul>
<p>6.<br />
Finally please <strong>zip the log file and send it as attachment</strong>, along with all the answers to <img src="http://www.lesnikowski.com/blog/wp-content/uploads/2011/02/email_address.gif" alt="support email address" title="support email address" width="167" height="16" class="alignnone size-full wp-image-1733" />.</p>
<p><strong>Thanks!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/i-have-problems-issuing-imap-pop3-smtp-command/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I have problems parsing the message</title>
		<link>http://www.lesnikowski.com/blog/i-have-problems-parsing-the-message/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=i-have-problems-parsing-the-message</link>
		<comments>http://www.lesnikowski.com/blog/i-have-problems-parsing-the-message/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 14:11:16 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[eml]]></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=1728</guid>
		<description><![CDATA[Mail.dll is a rock solid product, however most of the emails don&#8217;t follow rigorously the RFC specifications. In the following few steps we&#8217;ll help you gather the information we need to make Mail.dll parser better. If you are having the problems issuing IMAP, POP3, or SMTP command please go here. 1. First please check if [...]]]></description>
			<content:encoded><![CDATA[<p>Mail.dll is a rock solid product, however most of the emails don&#8217;t follow rigorously the RFC specifications. In the following few steps we&#8217;ll help you gather the information we need to make Mail.dll parser better.</p>
<p>If you are having the problems issuing IMAP, POP3, or SMTP command please <a href="http://www.lesnikowski.com/blog/i-have-problems-issuing-imap-pop3-smtp-command">go here</a>.</p>
<p>1.<br />
First please check if you have the latest version installed.</p>
<p>2.<br />
Please <strong>identify unique id (UID)</strong> of the message you are having problems with.</p>
<p>3.<br />
Next step is to <strong>download entire message and save it as raw eml</strong> file.<br />
Note that you are not parsing the email so you don&#8217;t need to use <em>MailBuilder</em> and <em>IMail</em> classes.</p>
<p><strong>IMAP version:</strong></p>
<pre class="brush: csharp;">
// C# code

long uid = 12345;

using (Imap imap = new Imap())
{
    imap.Connect(&quot;server&quot;);
    // imap.ConnectSSL(&quot;server&quot;); // if you need SSL connection.
    imap.Login(&quot;user&quot;, &quot;password&quot;);
    imap.SelectInbox();

    string eml = imap.GetMessageByUID(uid);
    string fileName = string.Format(&quot;c:\email_{0}.eml&quot;, uid);
    File.WriteAllText(fileName, eml, Encoding.UTF8);

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

Dim uid As Long = 12345

Using imap As New Imap()
	imap.Connect(&quot;server&quot;)
	' imap.ConnectSSL(&quot;server&quot;) ' if you need SSL connection.
	imap.Login(&quot;user&quot;, &quot;password&quot;)
	imap.SelectInbox()

	Dim eml As String = imap.GetMessageByUID(uid)
	Dim fileName As String = String.Format(&quot;c:\email_{0}.eml&quot;, uid)
	File.WriteAllText(fileName, eml, Encoding.UTF8)

	imap.Close()
End Using
</pre>
<p><strong>POP3 version:</strong></p>
<pre class="brush: csharp;">
// C# code

string uid = &quot;12345&quot;;

using (Pop3 pop3 = new Pop3())
{
    pop3.Connect(&quot;server&quot;);
    // pop3.ConnectSSL(&quot;server&quot;); // if you need SSL connection.
    pop3.Login(&quot;user&quot;, &quot;password&quot;);

    string eml = pop3.GetMessageByUID(uid));
    string fileName = string.Format(&quot;c:\email_{0}.eml&quot;, uid);
    File.WriteAllText(fileName, eml, Encoding.UTF8);

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

Dim uid As String = &quot;12345&quot;

Using pop3 As New Pop3()
	pop3.Connect(&quot;server&quot;)
	' pop3.ConnectSSL(&quot;server&quot;); ' if you need SSL connection.
	pop3.Login(&quot;user&quot;, &quot;password&quot;)

	Dim eml As String = pop3.GetMessageByUID(uid)
	Dim fileName As String = String.Format(&quot;c:\email_{0}.eml&quot;, uid)
	File.WriteAllText(fileName, eml, Encoding.UTF8)

	pop3.Close()
End Using
</pre>
<p>4.<br />
Please answer following questions:</p>
<ul>
<li>What <strong>exception </strong>are you getting?</li>
<li>What is the exception<strong> stack trace</strong>?</li>
<li>What is the exception <strong>message</strong>?</li>
<li>What result you expect?</li>
<li>What result are you getting?</li>
<li>Which .NET Framework version are you using?</li>
<li>Is it console, windows forms, windows service or web application?</li>
<li>If it is possible please attach the source code you are using</li>
</ul>
<p>5.<br />
Finally please <strong>zip the eml file and send it as attachment</strong>, along with all the answers to <img src="http://www.lesnikowski.com/blog/wp-content/uploads/2011/02/email_address.gif" alt="support email address" title="support email address" width="167" height="16" class="alignnone size-full wp-image-1733" />.</p>
<p><strong>Thanks!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/i-have-problems-parsing-the-message/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Send iCalendar recurring meeting requests</title>
		<link>http://www.lesnikowski.com/blog/send-icalendar-recurring-meeting-requests/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=send-icalendar-recurring-meeting-requests</link>
		<comments>http://www.lesnikowski.com/blog/send-icalendar-recurring-meeting-requests/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 16:57:16 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[iCalendar]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=1614</guid>
		<description><![CDATA[First add all necessary namespaces: // C# version using Lesnikowski.Client; using Lesnikowski.Mail; using Lesnikowski.Mail.Appointments; using Lesnikowski.Mail.Fluent; using Lesnikowski.Mail.Headers; ' VB.NET version Imports Lesnikowski.Client Imports Lesnikowski.Mail Imports Lesnikowski.Mail.Appointments Imports Lesnikowski.Mail.Fluent Imports Lesnikowski.Mail.Headers Now, we&#8217;ll create an appointment, specify it&#8217;s recurring options and send it: // C# version Appointment appointment = new Appointment(); Event newEvent = appointment.AddEvent(); [...]]]></description>
			<content:encoded><![CDATA[<p>First add all necessary namespaces:</p>
<pre class="brush: csharp;">
// C# version

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

Imports Lesnikowski.Client
Imports Lesnikowski.Mail
Imports Lesnikowski.Mail.Appointments
Imports Lesnikowski.Mail.Fluent
Imports Lesnikowski.Mail.Headers
</pre>
<p>Now, we&#8217;ll create an appointment, specify it&#8217;s recurring options and send it:</p>
<pre class="brush: csharp;">
// C# version

Appointment appointment = new Appointment();
Event newEvent = appointment.AddEvent();
newEvent.SetOrganizer(new Person(&quot;Alice&quot;, &quot;alice@example.org&quot;));
newEvent.AddParticipant(new Participant(&quot;Bob&quot;, &quot;bob@gmail.com&quot;));
newEvent.Description = &quot;We need to talk about the daily report&quot;;
newEvent.Summary = &quot;Daily report meeting&quot;;
newEvent.Start = new DateTime(2010, 11, 29, 16, 0, 0);
newEvent.End = new DateTime(2010, 11, 29, 17, 0, 0);
newEvent.Priority = 5;
newEvent.Class = EventClass.Public;

RecurringRule rule = newEvent.AddRecurringRule();
rule.Interval = 1;
rule.Until = new DateTime(2011, 12, 1); // -or- rule.Count = 10;

// Every week on  Mon, Tue, Wed, Thu Fri:
rule.Frequency = Frequency.Weekly;
rule.ByDay.AddRange(new[] {
    Weekday.Monday,
    Weekday.Tuesday,
    Weekday.Wednesday,
    Weekday.Thursday,
    Weekday.Friday });

Alarm alarm = newEvent.AddAlarm();
alarm.Description = &quot;Reminder&quot;;
alarm.BeforeStart(TimeSpan.FromMinutes(5));

IMail email = Mail.Text(&quot;Daily report meeting at 4PM&quot;)
    .Subject(&quot;Daily report meeting&quot;)
    .From(new MailBox(&quot;alice@example.org&quot;, &quot;Alice&quot;))
    .To(new MailBox(&quot;bob@example.org&quot;, &quot;Bob&quot;))
    .AddAppointment(appointment)
    .Create();

using (Smtp client = new Smtp())
{
    client.ConnectSSL(&quot;smtp.example.org&quot;);
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;);
    client.SendMessage(email);
    client.Close();
}
</pre>
<pre class="brush: vb;">
' VB.NET version

Dim appointment As New Appointment()
Dim newEvent As [Event] = appointment.AddEvent()
newEvent.SetOrganizer(New Person(&quot;Alice&quot;, &quot;alice@example.org&quot;))
newEvent.AddParticipant(New Participant(&quot;Bob&quot;, &quot;bob@gmail.com&quot;))
newEvent.Description = &quot;We need to talk about the daily report&quot;
newEvent.Summary = &quot;Daily report meeting&quot;
newEvent.Start = New DateTime(2010, 11, 29, 16, 0, 0)
newEvent.[End] = New DateTime(2010, 11, 29, 17, 0, 0)
newEvent.Priority = 5
newEvent.[Class] = EventClass.[Public]

Dim rule As RecurringRule = newEvent.AddRecurringRule()
rule.Interval = 1
rule.Until = New DateTime(2011, 12, 1)
' -or- rule.Count = 10;
' Every week on  Mon, Tue, Wed, Thu Fri:
rule.Frequency = Frequency.Weekly
rule.ByDay.AddRange(New Weekday() {Weekday.Monday _
                                   , Weekday.Tuesday _
                                   , Weekday.Wednesday _
                                   , Weekday.Thursday _
                                   , Weekday.Friday})

Dim alarm As Alarm = newEvent.AddAlarm()
alarm.Description = &quot;Reminder&quot;
alarm.BeforeStart(TimeSpan.FromMinutes(5))

Dim email As IMail = Mail.Text(&quot;Daily report meeting at 4PM&quot;) _
    .Subject(&quot;Daily report meeting&quot;) _
    .From(New MailBox(&quot;alice@example.org&quot;, &quot;Alice&quot;)) _
    .[To](New MailBox(&quot;bob@example.org&quot;, &quot;Bob&quot;)) _
    .AddAppointment(appointment).Create()

Using client As New Smtp()
    client.ConnectSSL(&quot;smtp.example.org&quot;)
    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;)
    client.SendMessage(email)
    client.Close()
End Using
</pre>
<p>This is how it looks like in Gmail:</p>
<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2010/11/RecurringAppointment1.jpg" alt="Recurring appointment" title="Recurring appointment" width="600" height="370" class="aligncenter size-full wp-image-1619" /></p>
<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2010/11/RecurringAppointment1.jpg" alt="Recurring appointment" title="Recurring appointment" width="600" height="370" class="aligncenter size-full wp-image-1619" /></p>
<p>Here are the few samples of how you can set the frequency:</p>
<p>Daily:</p>
<pre class="brush: csharp;">
// C# version

rule.Frequency = Frequency.Daily;
</pre>
<pre class="brush: vb;">
' VB.NET version

rule.Frequency = Frequency.Daily
</pre>
<p>Every month on last monday:</p>
<pre class="brush: csharp;">
// C# version

rule.Frequency = Frequency.Monthly;
rule.ByDay.Add(Weekday.LastMonday);
</pre>
<pre class="brush: vb;">
' VB.NET version

rule.Frequency = Frequency.Monthly
rule.ByDay.Add(Weekday.LastMonday)
</pre>
<p>Every month on second but last monday:</p>
<pre class="brush: csharp;">
// C# version

rule.Frequency = Frequency.Monthly;
rule.ByDay.Add(new Weekday(-2, Weekday.Monday));
</pre>
<pre class="brush: vb;">
' VB.NET version

rule.Frequency = Frequency.Monthly
rule.ByDay.Add(New Weekday(-2, Weekday.Monday))
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/send-icalendar-recurring-meeting-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A connection attempt failed</title>
		<link>http://www.lesnikowski.com/blog/connection-attempt-failed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=connection-attempt-failed</link>
		<comments>http://www.lesnikowski.com/blog/connection-attempt-failed/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 13:26:30 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[POP3]]></category>
		<category><![CDATA[SMTP]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=1587</guid>
		<description><![CDATA[If you are getting following or similar exception: &#8220;A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond&#8221; or &#8220;No connection could be made because the target machine actively refused it.&#8221; most likely you provided incorrect server, [...]]]></description>
			<content:encoded><![CDATA[<p>If you are getting following or similar exception:<br />
<strong>&#8220;A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond&#8221;</strong> or <strong>&#8220;No connection could be made because the target machine actively refused it.&#8221;</strong> most likely you provided <strong>incorrect server, port, and SSL usage</strong> configuration to <em>Connect</em>, or <em>ConnectSSL </em>methods.</p>
<p>Most email providers (like Gmail, Hotmail, Yahoo and others) use default ports.</p>
<p>Parameterless <em>Connect</em>() and <em>ConnectSSL</em>() and fluent interface use those ports.</p>
<p>Default ports for email protocols are:</p>
<table>
<tr>
<th>Protocol</th>
<th>Without SSL</th>
<th>With SSL</th>
</tr>
<tr>
<td><strong>IMAP</strong></td>
<td>143</td>
<td>993</td>
</tr>
<tr>
<td><strong>POP3</strong></td>
<td>110</td>
<td>995</td>
</tr>
<tr>
<td><strong>SMTP</strong></td>
<td>25</td>
<td>465</td>
</tr>
</table>
<p><strong>Please ask your email server administrator for server, port, and SSL usage</strong>,<br />
if those are not standard there is no way you can guess them.</p>
<p>Please also make sure that:</p>
<ul>
<li>you are using correct client class with protocol and port you plan to use (<em>Pop3 </em>class with POP3 protocol, <em>Imap </em>class with IMAP, and <em>Smtp </em>class with SMTP protocol)</li>
<li>the protocol you are trying to use is enabled on the server. Exchange or Gmail can have some protocols disabled by default
<li>you are using ConnectSSL when you require SSL, and Connect when you don&#8217;t</li>
<li><strong>firewall and antivirus software are disabled</strong> or configured correctly</li>
<p>Following articles can help you with that:<br />
<a href="http://www.lesnikowski.com/blog/download-emails-gmail-pop3">How to enable POP3 for Gmail</a><br />
<a href="http://www.lesnikowski.com/blog/download-emails-from-gmail">How to enable IMAP for Gmail</a><br />
<a href="http://technet.microsoft.com/en-us/library/bb124489.aspx">How to enable IMAP for Exchange</a>
</li>
</ul>
<p>Establishing connection using default port is simple:</p>
<pre class="brush: csharp;">
// C#

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

client.Connect(&quot;mail.example.com&quot;)
</pre>
<p>or if <strong>SSL</strong> is enabled:</p>
<pre class="brush: csharp;">
// C#

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

client.ConnectSSL(&quot;mail.example.com&quot;)
</pre>
<p>If you need to <strong>specify different port</strong> just <strong>use overloaded</strong> version of Connect method:</p>
<pre class="brush: csharp;">
// C#

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

client.Connect(&quot;mail.example.com&quot;, 999)
</pre>
<p>If you are using SSL:</p>
<pre class="brush: csharp;">
// C#

client.ConnectSSL(&quot;mail.example.com&quot;, 999);
</pre>
<pre class="brush: vb;">
' VB.NET

client.ConnectSSL(&quot;mail.example.com&quot;, 999)
</pre>
<p>If you need to specify different port using fluent interface use OnPort() method:</p>
<pre class="brush: csharp;">
// C# version

Mail.Text(@&quot;Hello&quot;)
  .To(&quot;to@mail.com&quot;)
  .From(&quot;from@mail.com&quot;)
  .Subject(&quot;Subject&quot;)
  .UsingNewSmtp()
  .Server(_server)
  .WithSSL()
  .OnPort(443)
  .WithCredentials(&quot;user&quot;, &quot;password&quot;)
  .Send();
</pre>
<p>Some servers require explicit SSL (Usually this triggers &#8220;The handshake failed due to an unexpected packet format&#8221; exception) please look at following articles for details:</p>
<ul>
<li><a href="http://www.lesnikowski.com/blog/use-ssl-with-imap">Use SSL with IMAP</a></li>
<li><a href="http://www.lesnikowski.com/blog/use-ssl-with-pop3">Use SSL with POP3</a></li>
<li><a href="http://www.lesnikowski.com/blog/use-ssl-with-smtp">Use SSL with SMTP</a></li>
</ul>
<p>If you have problems with SSL, your server may be using self-signed certificates:</p>
<ul>
<li><a href="http://www.lesnikowski.com/blog/the-remote-certificate-is-invalid-according-to-the-validation-procedure">The remote certificate is invalid according to the validation procedure</a></li>
</ul>
<p>Again when in doubt<strong> please ask your email server administrator for server, port, and SSL usage</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/connection-attempt-failed/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Logging in Mail.dll</title>
		<link>http://www.lesnikowski.com/blog/logging-in-mail-dll/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=logging-in-mail-dll</link>
		<comments>http://www.lesnikowski.com/blog/logging-in-mail-dll/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 18:03:54 +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=1478</guid>
		<description><![CDATA[To enable logging for Mail.dll clients (Imap, Pop3, Smtp) you only need to add following line before you connect: // C# version: Log.Enabled = true; // VB.NET version: Log.Enabled = True You can observe standard Visual Studio trace output or add a custom listener to Trace.Listeners collection. You can also enable logging using App.config file: [...]]]></description>
			<content:encoded><![CDATA[<p>To enable logging for Mail.dll clients (Imap, Pop3, Smtp) you only need to add following line before you connect:</p>
<pre class="brush: csharp;">
// C# version:

Log.Enabled = true;
</pre>
<pre class="brush: vb;">
// VB.NET version:

Log.Enabled = True
</pre>
<p>You can observe standard Visual Studio trace output or add a custom listener to <em>Trace.Listeners</em> collection.</p>
<p><img src="http://www.lesnikowski.com/blog/wp-content/uploads/2010/11/Mail_Log.png" alt="" title="Mail.dll Log" width="602" height="582" class="aligncenter size-full wp-image-1479" /></p>
<p>You can also enable logging using App.config file:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;configuration&gt;
    &lt;system.diagnostics&gt;
      &lt;switches&gt;
        &lt;add name=&quot;Mail.dll&quot; value=&quot;True&quot; /&gt;
      &lt;/switches&gt;
    &lt;/system.diagnostics&gt;
&lt;/configuration&gt;
</pre>
<p>You can create your custom TraceListener that writes log to file:</p>
<pre class="brush: csharp;">
// C# version:

internal class MyListener : TextWriterTraceListener
{
    public MyListener(string fileName)
        : base(fileName)
    {
    }

    public override void Write(string message, string category)
    {
        if (category == &quot;Mail.dll&quot;)
            base.Write(message, category);
    }

    public override void WriteLine(string message, string category)
    {
        if (category == &quot;Mail.dll&quot;)
            base.WriteLine(message, category);
    }
}
</pre>
<pre class="brush: vb;">
' VB.NET version

Friend Class MyListener
	Inherits TextWriterTraceListener
	Public Sub New(fileName As String)
		MyBase.New(fileName)
	End Sub

	Public Overrides Sub Write(message As String, category As String)
		If category = &quot;Mail.dll&quot; Then
			MyBase.Write(message, category)
		End If
	End Sub

	Public Overrides Sub WriteLine(message As String, category As String)
		If category = &quot;Mail.dll&quot; Then
			MyBase.WriteLine(message, category)
		End If
	End Sub
End Class
</pre>
<p>&#8230;then add it to Listeners collection:</p>
<pre class="brush: csharp;">
// C# version:

Log.Enabled = true;
Trace.Listeners.Add(new MyListener(@&quot;c:mail_log.txt&quot;));
Trace.AutoFlush = true;
</pre>
<pre class="brush: vb;">
// VB.NET version:

Log.Enabled = True
Trace.Listeners.Add(New MyListener(&quot;c:mail_log.txt&quot;))
Trace.AutoFlush = True
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/logging-in-mail-dll/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

