Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 623
Using SMTPmail in .NET
Is it possible to use SMTPmail in the .NET Framework? If so, how can this be accomplished?
Yes, it is possible to use SMTPmail in .NET, through the COM Interop. To use SMTPmail in .NET:
  1. Create the COM Interop Runtime Callable Wrapper for SMTPmail and add a reference to it. This can be done a couple of ways:
    1. Do both steps at the same time using the "Add References" dialog in VS.NET
      1. In your .NET project, right-click on the references node in the Solution viewer and ct Add Reference...
      2. Click Browse... and browse to the sasmtp.dll (This is usually located in either C:\program files\software artisans\SMTPMail\ or C:\program files\software artisans\FileUp\ or C:\program files\software artisans\sa-FileUp\)
      3. Select the sasmtp.dll
      4. Click Ok
    2. Creating your own COM Interop RCW (Using the command-line utility tlbimp.exe)
      1. Open the command prompt
      2. Navigate to the .NET Framework SDK utilities (usually located in C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin)
      3. Type in the command prompt: tlbimp "[Path to Dll]\sasmtp.dll" /out:sasmtpRCW.dll
      4. Place this dll into the bin directory of your application or complete step 1 above using the sasmtpRCW.dll
      See the link below for more information regarding this method.

  2. Create an instance of the SMTPmail object. In .NET this object is CoSMTPMailClass, which is part of the SASMTPLib namespace. For example,
    • With C#

      SASMTPLib.CoSMTPMailClass mailer = new SASMTPLib.CoSMTPMailClass();

    • With VB.NET

      Dim mailer As New CoSMTPMailClass()
Attached is a sample using SMTPmail in a .NET Web Application. This sample is the complete Visual Studio.Net project with the above process already completed.

Please note: The COM Interop RCW in this project was created using SMTPmail v2.3. If you have a different version of SMTPmail, then you will need to create your own using the steps above. Also, make sure that the COM dll registered on your system is the same dll which you use to create the COM Interop RCW.

For a more in-depth discussion on using COM objects within ASP.NET, which uses SMTPmail in the example, please see this article: http://www.aspheute.com/english/20000828.asp
Created : 6/22/2004 4:15:56 PM (last modified : 6/22/2004 4:15:55 PM)
Rate this article!