<?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/index.php/tag/smtp/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>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>Sending email with embedded image</title>
		<link>http://www.lesnikowski.com/blog/index.php/sending-email-with-embedded-image/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sending-email-with-embedded-image</link>
		<comments>http://www.lesnikowski.com/blog/index.php/sending-email-with-embedded-image/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 17:00:55 +0000</pubDate>
		<dc:creator>Pawel Lesnikowski</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Mail.dll]]></category>
		<category><![CDATA[SMTP]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.lesnikowski.com/blog/?p=381</guid>
		<description><![CDATA[We&#8217;ll use Mail.dll email client.

We need to create an email message
Use src=&#8221;cid:imageID&#8221; as image source in HTML
Add the image to Visuals collection using AddVisual method
Apply image id by setting ContentId
And finally send the message


// Use builder class to create an email
MailBuilder builder = new MailBuilder();

// Set From, To
builder.From.Add(new MailBox(&#34;alice@mail.com&#34;, &#34;Alice&#34;));
builder.To.Add(new MailBox(&#34;bob@mail.com&#34;, &#34;Bob&#34;));
builder.Subject = &#34;Test&#34;;

// Set [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ll use <a href="http://www.lesnikowski.com/mail/">Mail.dll email client</a>.</p>
<ol>
<li>We need to create an email message</li>
<li>Use <em>src=&#8221;<strong>cid</strong>:imageID&#8221;</em> as image source in HTML</li>
<li>Add the image to Visuals collection using <em>AddVisual</em> method</li>
<li>Apply image id by setting <em>ContentId</em></li>
<li>And finally send the message</li>
</ol>
<pre class="brush: csharp;">
// Use builder class to create an email
MailBuilder builder = new MailBuilder();

// Set From, To
builder.From.Add(new MailBox(&quot;alice@mail.com&quot;, &quot;Alice&quot;));
builder.To.Add(new MailBox(&quot;bob@mail.com&quot;, &quot;Bob&quot;));
builder.Subject = &quot;Test&quot;;

// Set HTML content (Notice the src=&quot;cid:...&quot; attribute)
builder.SetHtmlData(@&quot;&lt;html&gt;&lt;body&gt;&lt;img src=&quot;&quot;cid:image1&quot;&quot; /&gt;&lt;/body&gt;&lt;/html&gt;&quot;);

// SetHtmlData automatically extracts plaint text from html so,
// unless you want to specify plain text explicitly, you don't need to use this method:
builder.SetTextData(&quot;This is text version of th message.&quot;);

// Add image and set its Content-Id
MimeData visual = builder.AddVisual(@&quot;c:\image.jpg&quot;);
visual.ContentType = new ContentType(MimeType.Image, MimeSubtype.Jpeg);
visual.ContentId = &quot;image1&quot;;

IMail email = builder.Create();

// Send the message
using (Smtp smtp = new Smtp())
{
    smtp.Connect(&quot;mail.host.com&quot;);
    smtp.Ehlo(HeloType.EhloHelo, &quot;yourname&quot;);
    smtp.Login(&quot;user&quot;, &quot;password&quot;);
    smtp.SendMessage(email);
    smtp.Close(false);
}
</pre>
<p>And of course the VB.NET version of the same code:</p>
<pre class="brush: vb;">
' Use builder class to create an email
Dim builder As New MailBuilder()

' Set From, To
builder.From.Add(New MailBox(&quot;alice@mail.com&quot;, &quot;Alice&quot;))
builder.To.Add(New MailBox(&quot;bob@mail.com&quot;, &quot;Bob&quot;))
builder.Subject = &quot;Test&quot;

' Set HTML content (Notice the src=&quot;cid:...&quot; attribute)
builder.SetHtmlData(&quot;&lt;html&gt;&lt;body&gt;&lt;img src=&quot;&quot;cid:image1&quot;&quot; /&gt;&lt;/body&gt;&lt;/html&gt;&quot;)

' SetHtmlData automatically extracts plaint text from html so,
' unless you want to specify plain text explicitly, you don't need to use this method:
builder.SetTextData(&quot;This is text version of th message.&quot;)

' Add image and set its Content-Id
Dim visual As MimeData = builder.AddVisual(&quot;c:\image.jpg&quot;)
visual.ContentType = New ContentType(MimeType.Image, MimeSubtype.Jpeg)
visual.ContentId = &quot;image1&quot;

Dim email As IMail = builder.Create()

' Send the message
Using smtp As New Smtp()
	smtp.Connect(&quot;mail.host.com&quot;)
	smtp.Ehlo(HeloType.EhloHelo, &quot;yourname&quot;)
	smtp.Login(&quot;user&quot;, &quot;password&quot;)
	smtp.SendMessage(email)
	smtp.Close(False)
End Using
</pre>
<p>Same code using fluent interface:</p>
<pre class="brush: csharp;">
Mail.Html(@&quot;&lt;html&gt;&lt;body&gt;&lt;img src=&quot;&quot;cid:image1&quot;&quot; /&gt;&lt;/body&gt;&lt;/html&gt;&quot;)
        .Text(&quot;This is text version of th message.&quot;)
        .From(new MailBox(&quot;alice@mail.com&quot;, &quot;Alice&quot;))
        .To(new MailBox(&quot;bob@mail.com&quot;, &quot;Bob&quot;))
        .Subject(&quot;Test&quot;)
        .AddVisual(@&quot;c:\image.jpg&quot;)
        .SetContentId(&quot;image1&quot;)
        .SetContentType(
                new ContentType(MimeType.Image, MimeSubtype.Jpeg))
        .UsingNewSmtp()
        .WithCredentials(&quot;lesnikowski&quot;,&quot;password&quot;)
        .Server(&quot;mail.host.com&quot;)
        .Send();
</pre>
<p>And of course the VB.NET version using fluent interface:</p>
<pre class="brush: vb;">
Mail.Html(&quot;&lt;html&gt;&lt;body&gt;&lt;img src=&quot;&quot;cid:image1&quot;&quot; /&gt;&lt;/body&gt;&lt;/html&gt;&quot;) _
	.Text(&quot;This is text version of th message.&quot;) _
	.From(New MailBox(&quot;alice@mail.com&quot;, &quot;Alice&quot;)) _
	.To(New MailBox(&quot;bob@mail.com&quot;, &quot;Bob&quot;)) _
	.Subject(&quot;Test&quot;).AddVisual(&quot;c:\image.jpg&quot;) _
	.SetContentId(&quot;image1&quot;) _
	.SetContentType( _
                New ContentType(MimeType.Image, MimeSubtype.Jpeg)) _
	.UsingNewSmtp() _
	.WithCredentials(&quot;lesnikowski&quot;, &quot;password&quot;) _
	.Server(&quot;mail.host.com&quot;) _
	.Send()
</pre>
<p>You can download <a href="http://www.lesnikowski.com/mail/">Mail.dll email client here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lesnikowski.com/blog/index.php/sending-email-with-embedded-image/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
