Imap .NET Component - IMAP .NET Component, imap c#, imap vb, imap class
Home Search Knowledge Base Support

Support

Click here for access to live sales support.

For technical support please submit a ticket to the Help Desk.

 

Java and .NET Help

iPod shuffle offer

For a limited time get the newly re-designed iPod shuffle free with qualifying purchase.

Click for details.


News

Secure iNet Factory 8.0 Released
04/04/2008 02:24 PM

Updates to Email Factory for .NET and Secure iNet Factory
03/29/2008 04:06 PM

JSCAPE Secure FTP Server 3.9 Preview
03/14/2008 12:19 PM

AnyClient Service and Application Launched
03/12/2008 03:41 PM

JSCAPE Secure FTP Server 3.8 Released
02/12/2008 10:50 AM


Tutorials

Email Validation with Java
04/15/2008 02:04 PM

Sending HTML Based Email Using Java
03/11/2008 02:47 PM

Secure FTP Using Java and FTPS (FTP over SSL)
03/10/2008 04:08 PM

FTP Directory Listing Using Java
03/10/2008 03:57 PM

Sending Email Using Java
03/09/2008 03:43 PM

SSH Using Java
03/09/2008 02:53 PM


Articles

DMZ File Transfer Streaming
03/28/2008 11:57 AM

Phishing looks to FTP to distribute malware
03/13/2008 05:14 PM

Ad Hoc File Transfer Explained
03/13/2008 09:16 AM

Password Policies Made Easy
03/12/2008 03:03 PM


Feedback

Request a feature or component

Request a Java or .NET component


 

Imap .NET Component

The Imap .NET Component provides a simple interface for communicating with an IMAP4 (Internet Message Access Protocol v4) server.

download email factory for .netpurchase email factory for .net

Features

  • 100% managed C# - A highly scalable solution with no dependencies on 3rd party libraries.
  • Email address helper classes for parsing email addresses.
  • Royalty-Free Distribution - No runtime fees!
  • Easily retrieve attachments from email messages.
  • Serialization support allows you to easily store email messages to disk or a database
  • International support for multiple character sets.
  • Thread safe - Critical code blocks are synchronized for use by multiple threads.
  • Event Model - Multiple events for capturing IMAP activity
  • Integrated Help - Automatic integration of Help 2.0 documentation for Visual Studio .NET


Code Example

The following C Sharp example demonstrates retrieving messages from an IMAP4 server using the Imap .NET component.

/*
 * ImapExample.cs
 *
 * Copyright (c) 1999-2005 JSCAPE, LLC
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JSCAPE ("Confidential Information"). You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JSCAPE.
 */
using System;
using System.Collections;
using System.IO;
using System.Text;
using System.Threading;
using Jscape.Email;

namespace ImapExample {

   class ImapExample {

      public Imap myImap = null;
      // set default attachment folder
      public string attDir = "./messages/attachments/";

      public ImapExample(string hostname, string username, string password){
         myImap = new Imap(hostname, username, password);
         // turn on debug mode
         myImap.Debug = true;
         // don't delete messages from server
         myImap.DeleteMessages = false;

         // Subscribe to events
         myImap.ConnectedEvent += new Imap.ConnectedEventHandler(OnConnected);
         myImap.DisconnectedEvent += new Imap.DisconnectedEventHandler(OnDisconnected);
         myImap.DataReceivedEvent += new Imap.DataReceivedEventHandler(OnDataReceived);
         myImap.CommandSentEvent += new Imap.CommandSentEventHandler(OnCommandSent);
         myImap.MessageRetrievedEvent += new Imap.MessageRetrievedEventHandler(OnMessageRetrieved);

         // test current dir structure
         if (!Directory.Exists(attDir)) {
            Directory.CreateDirectory(attDir);
         }

         // connect to Imap server
         myImap.Connect();
         int mc = 0;
         // retrieve all email messages
         IEnumerator e = myImap.GetMessages();
         while(e.MoveNext()) {
            ++mc;
            int ac = 0;
            EmailMessage message = (EmailMessage)e.Current;
            // get attachments for each email, if any
            IEnumerator ea = message.GetAttachments();
            while(ea.MoveNext()) {
               ++ac;
               Attachment a = (Attachment)ea.Current;
               // get name of attached file, if any
               string filename = a.GetFilename();
               if (filename.Length == 0) {
                  // build temporary filename
                  filename = "att" + mc + "_" + ac + ".txt";
               }
               // get data for attached file
               byte[] data = a.GetFileData();
               // save the attachment
               FileStream fs = new FileStream(attDir + filename, FileMode.Create, FileAccess.Write);
               BinaryWriter w = new BinaryWriter(fs);
               w.Write(data, 0, data.Length);
               fs.Close();
            }
         }

         // your server may require a slight delay in order to respond.
         Thread.Sleep(100);
         // disconnect from server
         myImap.Disconnect();
      }

      [STAThread]
      static void Main(string[] args) {
         string hostname = "mail.ourserver.com";
         string username = "username@ourserver.com";
         string password = "password";

         ImapExample imapexample = new ImapExample(hostname, username, password);
      }

      public void OnConnected(object sender, ImapConnectedEventArgs e) {
         Console.WriteLine("Connected to {0}", e.Host);
      }
      public void OnDisconnected(object sender, ImapDisconnectedEventArgs e) {
         if (myImap.IsConnected()) {
            myImap.Disconnect();
         }
         Console.WriteLine("Disconnected.");
      }
      public void OnDataReceived(object sender, ImapDataReceivedEventArgs e) {
         Console.WriteLine("Response: "+e.Response);
      }
      public void OnCommandSent(object sender, ImapCommandSentEventArgs e) {
         Console.WriteLine("Command: "+e.Command);
      }
      public void OnMessageRetrieved(object sender, ImapMessageRetrievedEventArgs e) {
         // Uncomment the following line to display each message subject
         //Console.WriteLine("Message subject= "+e.Message.Subject);
      }

   }
}

download email factory for .netpurchase email factory for .net