Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

ASP.NET (VB) coding - using third party DLLs

Thread Tools
 
Search this Thread
 
Old 06 March 2004, 05:40 PM
  #1  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Default 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! )

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" )
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?

Last edited by Fatman; 06 March 2004 at 05:42 PM. Reason: Formatting
Old 06 March 2004, 06:58 PM
  #2  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Default

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.
Old 07 March 2004, 12:37 AM
  #3  
SCOSaltire
Scooby Regular
 
SCOSaltire's Avatar
 
Join Date: Mar 2001
Posts: 1,809
Likes: 0
Received 0 Likes on 0 Posts
Wink

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.

Last edited by SCOSaltire; 07 March 2004 at 12:39 AM.
Old 07 March 2004, 05:39 PM
  #4  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Default

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.
Old 07 March 2004, 07:42 PM
  #5  
SCOSaltire
Scooby Regular
 
SCOSaltire's Avatar
 
Join Date: Mar 2001
Posts: 1,809
Likes: 0
Received 0 Likes on 0 Posts
Default

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
Old 07 March 2004, 07:45 PM
  #6  
SCOSaltire
Scooby Regular
 
SCOSaltire's Avatar
 
Join Date: Mar 2001
Posts: 1,809
Likes: 0
Received 0 Likes on 0 Posts
Default

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.
Old 08 March 2004, 10:31 AM
  #7  
milo
Scooby Regular
 
milo's Avatar
 
Join Date: Nov 2001
Posts: 2,043
Likes: 0
Received 0 Likes on 0 Posts
Default

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).
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Darrell@Scoobyworx
Trader Announcements
26
30 January 2024 01:27 PM
Abx
Subaru
22
09 January 2016 05:42 PM
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
shorty87
Other Marques
0
25 September 2015 08:52 PM



Quick Reply: ASP.NET (VB) coding - using third party DLLs



All times are GMT +1. The time now is 12:15 PM.