Click here to Skip to main content
12,304,822 members (65,599 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# VB VB.NET
Hi,
I need the code to send the Mail using SMPT in C# or VB.net.

Thanks in advance
Posted 3-Feb-13 19:39pm
Comments
   
Not a question.
—SA
Uday P.Singh 4-Feb-13 4:40am
   
did you try something?
sumits007 4-Feb-13 7:05am
   
SmtpClient smtp = new SmtpClient();
smtp.Port=587; (For Gmail)
smtp.Host="smtp.gmail.com";


i was using these lines to add the host but because i was working in my company's host network so i was getting error. then i tired my company's host name instead of "smtp.gmail.com"
Irbaz Haider Hashmi 4-Feb-13 4:43am
   
You must try it first by yourself and if you get some issues then post here.
sumits007 4-Feb-13 7:06am
   
hey actually i am new here nd dont know the actual protocal here. but i did try first below lines
SmtpClient smtp = new SmtpClient();
smtp.Port=587; (For Gmail)
smtp.Host="smtp.gmail.com";


i was using these lines to add the host but because i was working in my company's host network so i was getting error. then i tired my company's host name instead of "smtp.gmail.com"
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Net;
using System.Net.Mail;

System.Web.Mail.MailMessage msg=new System.Web.Mail.MailMessage();
msg.ToAdd("Email");
msg.From("");
msg.Subject="";
msg.Body="";
SmtpClient smtp = new SmtpClient();
smtp.Port=587; (For Gmail)
smtp.Host="smtp.gmail.com";
smtp.Credentials=System.Net.Credentials("email", "password");
smtp.Send(msg);
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

using System.Net;
using System.Net.Mail;

Imports System.Net
Imports System.Net.Mail
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160530.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100