Solved

ASP.NET SMTPsvg.dll

Posted on 2004-10-16
5
1,266 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
ID: 12330713
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
ID: 12333836
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
ID: 12345487
Good point Aeros.
Works a treat - thanks muchly.

Dal
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12346212
Your very welcome my frined; Work smarter, not harder;)

Aeros
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

825 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