Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# 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
Sergey Alexandrovich Kryukov at 4-Feb-13 2:23am
   
Not a question.
—SA
Uday P.Singh at 4-Feb-13 4:40am
   
did you try something?
sumits007 at 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 at 4-Feb-13 4:43am
   
You must try it first by yourself and if you get some issues then post here.
sumits007 at 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 2

using System.Net;
using System.Net.Mail;
 
Imports System.Net
Imports System.Net.Mail
  Permalink  
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  

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



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2014
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