| Author |
Topic Search Topic Options
|
Leeb65
Groupie
Joined: 05 December 2003
Location: Germany
Status: Offline
Points: 62
|
Post Options
Thanks(0)
Quote Reply
Topic: Sending Emails 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
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
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)
|
|
|
 |
Leeb65
Groupie
Joined: 05 December 2003
Location: Germany
Status: Offline
Points: 62
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
Leeb65
Groupie
Joined: 05 December 2003
Location: Germany
Status: Offline
Points: 62
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
thataintchicken
Groupie
Joined: 19 January 2006
Location: United States
Status: Offline
Points: 49
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
Leeb65
Groupie
Joined: 05 December 2003
Location: Germany
Status: Offline
Points: 62
|
Post Options
Thanks(0)
Quote Reply
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.
Edited by Leeb65 - 14 February 2006 at 9:29am
|
Lee
|
 |
theSCIENTIST
Senior Member
Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
|
Post Options
Thanks(0)
Quote Reply
Posted: 31 July 2006 at 9:03am |
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 = " me@mlh.com" Dim mTo As String = " 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 |
|
|
|
 |
theSCIENTIST
Senior Member
Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
|
Post Options
Thanks(0)
Quote Reply
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?
|
|
|
 |