ASP.NET (VB) coding - using third party DLLs
#1
ASP.NET (VB) coding - using third party DLLs
I'm writing an ASP web app in VB.NET (Visual Studio.NET), and need a bit of help using third part DLLs. The DLL in question is Dimac's w3JMail - it's a mailer. I'm using the free version found via http://www.dimac.net/. I've run the installer, but I don't know how to use the DLL in code. What do I need to do to make the DLL available in code?
The guide book lists the following... (reproduced with thanks to Dimac! )
If I try the code "set msg = Server.CreateOBject( "JMail.Message" )" I get the error "Name 'msg' is not declared". So what should I declare it as? How else should/could I 'declare' the DLL?
The guide book lists the following... (reproduced with thanks to Dimac! )
First of all we need to create an instance of the jmail.message object:
set msg = Server.CreateOBject( "JMail.Message" )
Now lets turn on logging to make any debugging easier:
msg.Logging = true
We need to provide a sender as well as a recipient:
msg.From = "john.doe@mydomain.com"
msg.FromName = "John Doe"
msg.AddRecipient "lisa.simpson@springfi eld.com"
The addRecipient method can be used multiple times to add more than one
recipient. Also, it can take an optional parameter which specifi es the name of
the recipient:
msg.AddRecipient "deliveryboy@futurama.com", "Fry"
msg.AddRecipient "theblob@southpark.com", "Cartman"
Ok, now we should add a subject:
msg.Subject = "How are you?"
and a body. The example below also shows how to add carriage returns:
msg.Body = "This w3 JMail stuff rocks!" & vbCrLf
Another way to create the body of the e-mail is to use the appendText
method, which can be used multiple times to build the e-mail body:
msg.appendText "Here’s some text."
msg.appendText "And here’ s some more"
There you go, the e-mail message is complete, now all we need is to send it.
To do that we need to enter the address of a valid mail server which accepts
incoming e-mails from your web server:
msg.Send( "mail.myDomain.com" )
set msg = Server.CreateOBject( "JMail.Message" )
Now lets turn on logging to make any debugging easier:
msg.Logging = true
We need to provide a sender as well as a recipient:
msg.From = "john.doe@mydomain.com"
msg.FromName = "John Doe"
msg.AddRecipient "lisa.simpson@springfi eld.com"
The addRecipient method can be used multiple times to add more than one
recipient. Also, it can take an optional parameter which specifi es the name of
the recipient:
msg.AddRecipient "deliveryboy@futurama.com", "Fry"
msg.AddRecipient "theblob@southpark.com", "Cartman"
Ok, now we should add a subject:
msg.Subject = "How are you?"
and a body. The example below also shows how to add carriage returns:
msg.Body = "This w3 JMail stuff rocks!" & vbCrLf
Another way to create the body of the e-mail is to use the appendText
method, which can be used multiple times to build the e-mail body:
msg.appendText "Here’s some text."
msg.appendText "And here’ s some more"
There you go, the e-mail message is complete, now all we need is to send it.
To do that we need to enter the address of a valid mail server which accepts
incoming e-mails from your web server:
msg.Send( "mail.myDomain.com" )
Last edited by Fatman; 06 March 2004 at 05:42 PM. Reason: Formatting
#2
Found it! In the tree-view Solution Explorer, right-click on References, and then Add Reference. This exposes the .NET components and COM objects installed. Choose your object, and click OK. The properties of that object are then available via the name.method form.
#3
uv found it - but why use a 3rd party?
.Net has built in classes that are very good:
Imports System.Web.Mail
Dim mmMail as New MailMessage()
mmMail.From = sFrom
mmMail.To = sTo
mmMail.Subject = sSubject
mmMail.Body = sBody
Dim maAttachment as New MailAttachment(Server.MapPath(".") & "\scooby")
mmMail.Attachments.Add(maAttachment)
Smtp.Send(mmMail)
If the DLL u are referencing is in unmanaged code - then ull probably need to make ur ASP pages in the mode compatible with COM+ by using the attribute ASPCompat="true" in order to get the best performance.
.Net has built in classes that are very good:
Imports System.Web.Mail
Dim mmMail as New MailMessage()
mmMail.From = sFrom
mmMail.To = sTo
mmMail.Subject = sSubject
mmMail.Body = sBody
Dim maAttachment as New MailAttachment(Server.MapPath(".") & "\scooby")
mmMail.Attachments.Add(maAttachment)
Smtp.Send(mmMail)
If the DLL u are referencing is in unmanaged code - then ull probably need to make ur ASP pages in the mode compatible with COM+ by using the attribute ASPCompat="true" in order to get the best performance.
Last edited by SCOSaltire; 07 March 2004 at 12:39 AM.
#4
This is probably a dumb question, but what is managed code? I'm using this 3rd-party DLL since that is what the web host has installed on their server -- that reason alone. The syntax for VMail is very similar to system.web.mail anyway.
#5
managed code is code that is run by the .Net CLR.
This is any code written and compiled to the language of the CLR - the intermediate language.
In ASP.Net - when ur Code Behind is executed its the CLR that manages the execution of this code.
The COM stuff is still run by com - the reference that you made effectively creates a .net proxy that allows the code behind to run the COM+ component.
Because the COM+ is not executed by the CLR, its known as unmananged code - coz the CLR aint managing the garbbage collection, memory allocation etc.
whether u use always managed (.net) or unmanaged (com) stuff depends on what ur doing - i aint saying ur wrong
This is any code written and compiled to the language of the CLR - the intermediate language.
In ASP.Net - when ur Code Behind is executed its the CLR that manages the execution of this code.
The COM stuff is still run by com - the reference that you made effectively creates a .net proxy that allows the code behind to run the COM+ component.
Because the COM+ is not executed by the CLR, its known as unmananged code - coz the CLR aint managing the garbbage collection, memory allocation etc.
whether u use always managed (.net) or unmanaged (com) stuff depends on what ur doing - i aint saying ur wrong
#6
ull get access to the .net mail classes because the are part of .net - thats the advantage of it - base .net llibraries are always available
Theres nothing wrong in using the 3rd party stuff - it might be better - i dunno - ive only studied it, not used it in ernest yet.
Theres nothing wrong in using the 3rd party stuff - it might be better - i dunno - ive only studied it, not used it in ernest yet.
#7
agreed - use the built-in .net classes for this for a huge number of reasons.
ONLY go com when the .net classes will not do what you need (for instance if you already have business logic in a com class and don't want to re-code).
ONLY go com when the .net classes will not do what you need (for instance if you already have business logic in a com class and don't want to re-code).
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
Sam Witwicky
Engine Management and ECU Remapping
17
13 November 2015 10:49 AM