Using MailBee.NET Objects in Your Projects

The following steps demonstrate how to add a reference to MailBee.NET Objects libraries in your applications.

Referencing MailBee.NET Objects library

There are multiple ways for this, NuGet Package Manager is the easiest option.

In Visual Studio via Package Manager Console

Run this command:

Install-Package MailBee.NET

The latest version of MailBee.NET Objects assembly appears in your project.

If your app makes use of Ews component, then run:

Install-Package MailBee.NET.EWS

EWS functionality is supported for .NET 3.5/4.0/4.5+ and .NET Standard 2.0 (.NET Core 2.0+, UWP for Windows 10 Fall Creators Update and newer).

If your app makes use of HtmlToPdf class (PDF functionality), then run:

Install-Package MailBee.NET.PDF

PDF functionality is supported for .NET 2.0/3.5/4.0/4.5+ (.NET Framework only, .NET Core is not supported).

In Visual Studio via Add Reference

If NuGet is not an option..

Multiple versions of MailBee.NET.dll are shipped with the product, and get installed in various sub-folders of "C:\Program Files (x86)\MailBee.NET Objects" common folder:

In case if your app uses Ews component, you'll also need to add a reference to MailBee.NET.EWS.dll (available for .NET 3.5/4.0/4.5+ and .NET Standard 2.0), and Microsoft.Exchange.WebServices.dll (or Microsoft.Exchange.WebServices.NETStandard.dll for .NET Standard 2.0).

In case if your app uses Pdf component, you'll also need to add a reference to MailBee.NET.PDF.dll (available for .NET 2.0/3.5/4.0/4.5), and iTextSharp.dll. There is no PDF support for .NET Standard / .NET Core. Note that MailBee.NET installer won't install the PDF-related DLLs unless you tick the correponding checkbox during the installation process.

In the steps below, it's assumed your Visual Studio project is named EmailApp.

  1. In the Solution Explorer, right-click the project name (EmailApp), and select Add Reference command in the context menu.
  2. In the appeared Add Reference dialog, find MailBee.NET Objects for your .NET Framework version (in case if you installed multiple versions). You may need to enlarge this dialog window to see file paths of the dlls because .NET Framework version of each dll is stored in the path, e.g. "C:\Program Files (x86)\MailBee.NET Objects\4.5\MailBee.NET.dll").
  3. Alternatively, if you have a newer version of MailBee.NET.dll (more recent than the one which came with the installer) or the version you're looking for is not in the list, you can click Browse button and manually locate MailBee.NET.dll file. Then double-click the reference to add it into the list and click OK. Now MailBee.NET Objects library gets referenced from your application.
  4. In the properties of the reference added, make sure Copy Local setting is True.

In newer versions of Visual Studio, path to the dll is not shown by default so you may need to hover mouse cursor over to see the path (and determine the version). In this case, it's .NET 4.5+ version of MailBee.NET.dll:

Again, this is only important if you have multiple MailBee.NET entries here (for different .NET Framework versions).

In the steps above, we uploaded a copy of MailBee.NET.dll into the project folder and referenced this copy. The original MailBee.NET.dll is no longer needed. The application can be easily XCOPY deployed using this method.

You can find the detailed guide on how to reference MailBee.NET.dll at Import namespaces and set license key article (the article belongs to "IMAP and POP3" guide but the approach remains the same for all MailBee.NET components).

In non-Visual Studio environment

To reference MailBee.NET Objects library in non-Visual Studio application, you should manually upload MailBee.NET.dll file into the /bin folder under the root folder of your application. If there is no /bin folder, you should create it first.

The application referencing MailBee.NET Objects library in such a way can take advantage of XCOPY deployment.

Importing MailBee namespaces

Once MailBee.NET Objects library is referenced from your application, the next step is to import namespaces declared in the library, into your application.

In the code below, we import all the available namespaces. You may keep only those declarations of namespaces which are actually used by your application.

Place the lines below at the top of your code file:

using MailBee;
using MailBee.DnsMX;
using MailBee.Mime;
using MailBee.EwsMail;
using MailBee.SmtpMail;
using MailBee.Pop3Mail;
using MailBee.ImapMail;
using MailBee.Security;
using MailBee.AntiSpam;
using MailBee.AddressCheck;
using MailBee.Outlook;
using MailBee.Pdf;
Imports MailBee
Imports MailBee.DnsMX
Imports MailBee.Mime
Imports MailBee.EwsMail
Imports MailBee.SmtpMail
Imports MailBee.Pop3Mail
Imports MailBee.ImapMail
Imports MailBee.Security
Imports MailBee.AntiSpam
Imports MailBee.AddressCheck
Imports MailBee.Outlook
Imports MailBee.Pdf

Depending on your MailBee.NET edition, some namespaces may not be available (e.g. PDF component is not available in .NET Core and UWP).

Assigning the license key

To unlock the product in trial or permanent mode, you need to assign the license key. The license key can be specified in config file (app.config, web.config, or machine.config), in Windows registry (SaveKey and SaveKeyGui utilities can place the license key into the registry), or in static (Shared in Visual Basic) MailBee.Global.LicenseKey property. See Using License Keys topic on how to obtain and specify the license key.

Usage example

Now you can use MailBee.NET Objects classes in your application. In this sample, we send a simple e-mail message with a single line of code.

Smtp.QuickSend("", "", "Hello", "How are you?");
Smtp.QuickSend("", "", "Hello", "How are you?")

Send feedback to AfterLogic

Copyright © 2006-2023 AfterLogic Corporation. All rights reserved.