VS.NET 2010/2012 Users Click Here   

HOMECONTACT PRODUCTS DOWNLOADS PURCHASE TESTIMONIALS FORUMS COMPANY CONTACT
Home
Products
Downloads
Purchase
Licensing
Licensing FAQ
Software Updates
Support Forums
Testimonials
Feature Requests
Guarantee
About Us
Contact Us
Hosting Companies
Privacy Policy
   
Shopping Cart


Search

aspNetMime: Using it in a ASP (COM) Applicatioin

by Dave 29. September 2011 04:00

An evaluator, Chuck, had a request to use aspNetMime from a classic ASP (COM) application.

Normally, aspNetMime is used in .NET application (C#, VB.NET, etc.. winforms, windows services, and ASP.NET applications). However, occasionally a developer will need to use our assemblies (in this example, aspNetMime) from classic COM applications.

To do this, we must first download the aspNetMime.dll from the website (www.advancedintellect.com)

By default, when you run the aspNetMime.msi install file, it will be installed in the GAC (global assembly cache). However, if you want to manually do this (or if you moved the aspNetMime.dll to a new server), you can use the gacutil.exe (provided by VS.NET).

From a command prompt, call:

        gacutil.exe /I aspNetMime.dll

Once aspNetMime is installed in the GAC, it must be exposed for COM (ASP, VBScript, VB4+). To do this, you need to use the regasm.exe tool (also provided by VS.NET).

To do this, again from a command prompt, execute the following command:

        regasm.exe aspNetMime.dll

Regasm.exe will create a COM wrapper around the aspNetMime.dll, and install the required registry entries, so that aspNetMime can be called for COM.

Once that is done, aspNetMime can now be used in a classic ASP page.  Here is an example, that reads in an email file, and displays the subject and body on a page:

<% Option Explicit%>

<%
Dim mime
Dim lic
Dim subject
Dim plainText
Dim htmlText

'Load the license file
 Set lic = Server.CreateObject( "aspNetMime.MimeMessageLicense" )
 lic.LoadLicenseFile  "c:\aspNetMime.xml.lic"  'loads the license in memory
 
'create the MimeMessage object
 Set mime = Server.CreateObject( "aspNetMime.MimeMessage" )

'load the test email
mime.LoadFromFile( "c:\temp\aspTest.eml")

'read the subject
subject = mime.Subject.Value
Response.Write("<BR>Subject: " + subject)

'get the plain text body (if one exists)
if( not mime.TextMimePart is Nothing ) then
 plainText= mime.TextMimePart.DecodedText
 Response.Write("<HR>")
 Response.Write(plainText)
End if

'get the Html body (if one exists)
if( not mime.HtmlMimePart is Nothing ) then
 htmlText = mime.HtmlMimePart.DecodedText
 Response.Write("<HR>")
 Response.Write(htmlText)
End if
%>

As always, if anyone has any questions, feel free to contact me using the Contact Us page, and referene this article.

Thanks!
Dave Wanta

 

 

Testimonial

This is a great product that has greatly reduced my development time! "

S.Ellis | eCreditGroup

Read more testimonials
ListNanny aspNetDNS aspNetEmail aspNetPOP3 aspNetMX aspNetMIME aspNetPING aspNetTraceRoute aspNetIMAP aspNetMHT