Secure the Email in Your .NET Apps with SSL Email Components
page 13 of 14
by John Alessi
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 49340/ 108

Retrieving Mail with IMAP3 over an SSL Connection
VB.Net Sample
Dim objIMAP4 As New IMAP4
Dim objSSL As New SSL
objIMAP4.Connect("mail.domain.com",
                 993, objSSL.GetInterface())
objIMAP4.Login("account, "password")
objIMAP4.SelectMailbox("Inbox")
Dim env As Envelope
Dim envelopes As EnvelopeCollection
envelopes = objIMAP4.GetEnvelopes()
For Each env In envelopes
   Console.WriteLine(env.Subject)
Next
objIMAP4.Logout()
Console.ReadLine()
 
 
C# Sample
</span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt">IMAP4 objIMAP4 = new IMAP4();<o:p></o:p></span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt">SSL objSSL = new SSL();<o:p></o:p></span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt">objIMAP4.Connect("mail.domain.com",<o:p></o:p></span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt"><span style="mso-spacerun: yes">                 </span>993, objSSL.GetInterface());<o:p></o:p></span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt">objIMAP4.Login("account","password");<o:p></o:p></span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt">objIMAP4.SelectMailbox("Inbox");<o:p></o:p></span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt">EnvelopeCollection envelopes = objIMAP4.GetEnvelopes();<o:p></o:p></span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt">foreach (Envelope env in envelopes)<o:p></o:p></span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt"><span style="mso-spacerun: yes">   </span>Console.WriteLine(env.Subject);<o:p></o:p></span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt">objIMAP4.Logout();<o:p></o:p></span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt">Console.ReadLine();</span></pre><pre><span style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 10.0pt">
This example uses the IMAP4 component to make a connection on port 993, the standard port for IMAP communications over SSL.  The example displays the subject of every message found in the "Inbox" without parsing the message, by using the "envelopes" feature of the IMAP component.

View Entire Article

User Comments

Title: NO TEXT WRAP!   
Name: Stuart Welwood
Date: 2006-02-21 2:07:44 PM
Comment:
The text of this article does not wrap - VERY difficult to read!

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-24 2:47:07 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search