Print Page | Close Window

Sending Emails

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=18227
Printed Date: 28 March 2026 at 5:58pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Sending Emails
Posted By: Leeb65
Subject: Sending Emails
Date Posted: 01 February 2006 at 3:14pm

Hi all,

How do you send emails through code behind not using outlook, but through the SMTP server on the local server.
 
I need to send text emails, I can send HTML no probs.
 
The main problem I can see is that I have to send "äöüß" special characters.
 
thanks,
 


-------------
Lee

http://www.rheinsitemedia.de">



Replies:
Posted By: michael
Date Posted: 01 February 2006 at 4:07pm
Not sure if you are using asp.net 2.0 but there it is more than simple and it should not matter if you have umlauts in the Message Text.

Dim MailObj As New System.Net.Mail.SmtpClient
MailObj.Host = "localhost"
MailObj.Send(EmFrom.Text, EmTo.Text, EmSubj.Text, EmMsg.Text)

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: Leeb65
Date Posted: 02 February 2006 at 6:53am
Thanks michael,
 
I am using asp.net 1.1. 
 
What you have written is the same as I have, but for some strange reason I have always had the same problem. In HTML the emails are sent because I can use ä etc.
 
 


-------------
Lee

http://www.rheinsitemedia.de">


Posted By: Leeb65
Date Posted: 02 February 2006 at 10:03am
Okay, I changed the code back, so all HTML formating is now Text formating and it runs. Strange!!
 
 


-------------
Lee

http://www.rheinsitemedia.de">


Posted By: thataintchicken
Date Posted: 05 February 2006 at 12:14am
Have you tried using the SmtpMail Object?


<%@ Import Namespace="System.Web.Mail %>
......
<%
Dim strEmailTo As String = "customer@example.com"
Dim strEmailFrom As String = "employee@example.com"
Dim strEmailSubject As String = "Importaint email!"
Dim strEmailBody As String

strEmailBody = "I'm just kidding! This message isn't really all that " & _
    "importaint. Thanks for your time!"

Send(strEmailFrom, strEmailTo, strEmailSubject, strEmailBody)





-------------
"I not only use all of the brains I have, but all I can borrow."
    --Woodrow Wilson, 28th President of the United States


Posted By: Leeb65
Date Posted: 10 February 2006 at 5:02pm

I only use the SMTPMail object.

I have written a wrapper for it so it's in German and some functions are easier to use.


-------------
Lee

http://www.rheinsitemedia.de">


Posted By: theSCIENTIST
Date Posted: 31 July 2006 at 9:03am
Originally posted by michael michael wrote:

Dim MailObj As New System.Net.Mail.SmtpClient
MailObj.Host = "localhost"
MailObj.Send(EmFrom.Text, EmTo.Text, EmSubj.Text, EmMsg.Text)
 
I'm not using asp.net 2.0 and the above code fails with [ Compiler Error Message: BC30002: Type 'System.Net.Mail.SmtpClient' is not defined. ], is it only for 2.0?
 
I have included this [ <%@ Import Namespace="System.Web.Mail" %> ] on top and it still fails.
 
Here's my code:
 

  Sub ContactUs()
    Dim MailObj As New System.Net.Mail.SmtpClient
    Dim mFrom As String = " mailto:me@mlh.com - me@mlh.com "
    Dim mTo As String = " mailto:me@mlh.com - me@mlh.com "
    Dim mSub As String = "Subject line"
    Dim mMsg As String = "This is the message"
    MailObj.Host = "localhost"
    MailObj.Send(mFrom, mTo, mSub, mMsg)
    Response.Write(vbCrLf & "Email sent.")
  End Sub


-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com


Posted By: theSCIENTIST
Date Posted: 31 July 2006 at 10:11am
I've got it now, I guess the above [ System.Net.Mail.SmtpClient ] is only for v2.0, I'm using the MailMessage() which brings me to my next question, which is the fastest and resourceless method to send simple text emails?

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com


Posted By: scottage
Date Posted: 09 January 2007 at 3:28pm
As far as I know the fasted (as in writing code) method is to use the System.Web.Mail.SMTPMail classes where this generates the fastest possible code execution is an entirely different matter. I have written a SMTP mail class that delivers directly to the mail host for the destination domain but this was to get the return codes from the remote system not to be fast. If your ultimate goal is to send bulk emails then an Ironport box is the solution but it's a huge investment that's only worth while if you can support the bandwidth that it will consume

-------------
http://www.realwebdevelopers.com" rel="nofollow - Developing real world websites



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net