System.Web.Mail FAQ

Complete FAQ Listing


2.9 How do I change the port number? Printer Friendly   Email This FAQ   Discuss

To change the port number, you will need to chane the http://schemas.microsoft.com/cdo/configuration/smtpserverport field.
The following code snippet demonstrates this technique.

[ C# ]
MailMessage mail = new MailMessage(); 
mail.To = "me@mycompany.com"; 
mail.From = "you@yourcompany.com"; 
mail.Subject = "this is a test email."; 
mail.Body = "Some text goes here"; 
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "your port number"); 
SmtpMail.SmtpServer = "mail.mycompany.com"; 
SmtpMail.Send(mail);

[ VB.NET ]
Dim mail As New MailMessage()
   mail.To = "me@mycompany.com"
   mail.From = "you@yourcompany.com"
   mail.Subject = "this is a test email."
   mail.Body = "Some text goes here"
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "your port number") 'Put port number here

   SmtpMail.SmtpServer = "mail.mycompany.com" 'your real server goes here

   SmtpMail.Send(mail)

 

Discuss This FAQ Item
Got a question? Another Suggestion? Want to post your solution? Discuss it below.
New Post
  • ICS Problems    [ Reply ]
  • missing method    [ Reply ]
  • How do I give Non US-ASCII character in Subject of Mail Message    [ Reply ]
  • smtpMail.SmtpServer    [ Reply ]
  • to change the port number in vb.net    [ Reply ]
    • RE: to change the port number in vb.net    [ Reply ]
  • error 503 "server requires authentication"    [ Reply ]
  • Problem with SMTP mail    [ Reply ]
    • RE: Problem with SMTP mail    [ Reply ]
  • Problem in sending mails to differentservers    [ Reply ]
  • problem with sent email    [ Reply ]
    • RE: problem with sent email    [ Reply ]
  • sent mails to yahoo    [ Reply ]
  • htmlemail    [ Reply ]
    • RE: htmlemail    [ Reply ]
  • email query    [ Reply ]
  • How to send email using VB.Net from Windows Application?    [ Reply ]
  • Read Smtp Details given in inetmgr    [ Reply ]