Solved

ASP.NET SMTPsvg.dll

Posted on 2004-10-16
5
1,234 Views
Last Modified: 2013-11-25
Hi guys

Is anyone aware whether or not you can use the Active Server Component ASPMAIL (SMTPsvg.dll) from ASP.NET/VB.NET? This is my webhost's emailing component.

The documentation says I need to use:
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

I also read that I need to use the page directive: aspcompat="true" if using ASPX rather an ASP. But this gives me the error:

Parser Error Message: The current trust level does not allow use of the 'AspCompat' attribute

My ISP tell me to 'rename the aspx to asp', and that's as much help as they will give. Have tried creating a reference to smtpsvg.dll, but this hasn't solved the problem.

I will do it in ASP if I have to, but would rather keep all code in ASPX.VB (as I'm passing a password for email).

Any help gratefully received!

Thanks.
0
Comment
Question by:dalsandhu
  • 2
5 Comments
 
LVL 15

Assisted Solution

by:Timbo87
Timbo87 earned 50 total points
Comment Utility
Have you considered using the .NET Framework's built-in mail sending features?

http://www.aspheute.com/english/20000918.asp
http://www.developer.com/net/asp/article.php/3096831
0
 
LVL 17

Accepted Solution

by:
AerosSaga earned 450 total points
Comment Utility
do it this way:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
try
Dim objEmailMessage As System.Web.Mail.MailMessage
Dim objSMTPServer As System.Web.Mail.SmtpMail
objSMTPServer.SmtpServer = "mycomputername"
objEmailMessage = New System.Web.Mail.MailMessage
With objEmailMessage
.To = "destinationemail@address.com"
.From = txtFrom.Text
.Subject = "Great Job!"
.Body = "Want all my money?"
.BodyFormat = MailFormat.Html
End With
objSMTPServer.Send(objEmailMessage)
catch exc as exception
response.write(exc.innerexception.innerexception.message)
end try
End Sub
____________________________________________________________________________________________
Or
_____________________________________________________________________________________________

Private Sub Page_Load(sender As Object, e As System.EventArgs)
   Dim mail As New MailMessage()
   mail.To = "me@mycompany.com"
   mail.From = "you@yourcompany.com"
   mail.Subject = "this is a test email."
   mail.BodyFormat = MailFormat.Text
   mail.Body = "Some text goes here"
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here") 'set your username here
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret") 'set your password here
   SmtpMail.SmtpServer = "mail.mycompany.com" 'your real server goes here
   SmtpMail.Send(mail)
End Sub 'Page_Load
-------------------------------------------------------------------------------------------------
For ReadReceipt
  .Headers.Add("Return-Receipt-To", "me@mydomain.com")

Why do it the long way with old school equipment???

Aeros
0
 

Author Comment

by:dalsandhu
Comment Utility
Good point Aeros.
Works a treat - thanks muchly.

Dal
0
 
LVL 17

Expert Comment

by:AerosSaga
Comment Utility
Your very welcome my frined; Work smarter, not harder;)

Aeros
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now