Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I need the code to send the Mail using SMPT in C# or VB.net.

Thanks in advance
Posted
Comments
Sergey Alexandrovich Kryukov 4-Feb-13 2:23am    
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"

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);
 
Share this answer
 
C#
using System.Net;
using System.Net.Mail;


VB
Imports System.Net
Imports System.Net.Mail
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900