Send e-mails with a webform

  • Thread starter Thread starter Esteban GN
  • Start date Start date
E

Esteban GN

Hi group,
I have the following code:
It works fine, but I want to use another smtp server and it use the TCP Port
5000
There is a way to change the default smtp port (25) with aditional code?
Thanks in advance.


Imports System.Web.Mail

Partial Class AddCasos

Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim mailMessage As New MailMessage()

mailMessage.From = TextBox1.Text

mailMessage.To = (e-mail address removed)

mailMessage.Subject = TextBox2.Text

mailMessage.BodyFormat = MailFormat.Text

mailMessage.Body = TextBox3.Text

mailMessage.Priority = MailPriority.Normal

SmtpMail.SmtpServer = "server05"

'mail server used to send this email. modify this line based on your mail
server

SmtpMail.Send(mailMessage)

Response.Redirect("casesend.aspx")

End Sub

End Class
 
Thank you!
It works fine.

KR
sloan said:
If you implement my "Smarter SMTP Settings" solution, you won't get
screwed with different environments:

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry


But no, you have to set the
System.Net.Mail.SmtpClient.Port
property (2.0)


Or in 1.1
MailMessage emailMsg = new MailMessage();
emailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
portNum);


That's why my Wrapper Stuff is "smarter".
 
Back
Top