Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I am sangeetha. I have been creating a website.so i need a text provision for user to enter their complaints and feedback and that should sent to administrators email id.So i need code for sending that complaint to an email id and please specify the namespace and class need for that.Please help me
Posted
Comments
Feremabight 2-Mar-16 8:12am    
As another approach you could use this email dll for C#. I hope it helps.

There is a generic routine for sending email here: Sending an Email in C# with or without attachments: generic routine.[^]
 
Share this answer
 
Comments
Uday P.Singh 25-Jun-11 4:40am    
nice link my 5 :)
Espen Harlinn 25-Jun-11 11:28am    
My 5 - that must be one of the most reused aswers on CP
OriginalGriff 25-Jun-11 12:02pm    
Why not? It's one of the most reused questions! :laugh:
Espen Harlinn 25-Jun-11 12:09pm    
As a developer I kind of like reuse, we're even supposed to be good at it :)
Sergey Alexandrovich Kryukov 25-Jun-11 20:05pm    
Code re-use is nothing like a virtue though; the buzz work was coined by those who use to totally crappy code; a little step out of it was called "code reuse".
--SA
Try This code

VB
Dim mes As String = String.Empty
Dim sTo As String = "[To Address]"
Dim sFrom As String = "[From Address]"
Dim sSubject As String = "[Subject]"
Dim sMailServer As String = "127.0.0.1"
Dim MyMail As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
MyMail.From = sFrom
MyMail.To = sTo
MyMail.Subject = sSubject
MyMail.Body = "[Your Message]"
MyMail.BodyEncoding = Encoding.UTF8
MyMail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = sMailServer
Try
    SmtpMail.Send(MyMail)
    PRes.InnerHtml = "Your Mail is Successfully Sended"
Catch ex As Exception
    PRes.InnerHtml = "Your Mail is not Sended. Because Of this Error : " & ex.Message
End Try


Thanks.
 
Share this answer
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
namespace MyMail
{
    class SendMail
    {
        SmtpClient objSmtpClient = new SmtpClient();
        MailMessage objMailMessage = new MailMessage();
        MailAddress objMailAddress;
        public SendMail()
        {
           // objSmtpClient.Host = "";
           // objSmtpClient.Port = ;
            objSmtpClient.Host = "smtp.gmail.com";
            objSmtpClient.Port = 465;
        }
       public  bool Sendmail(string mail_From,string mail_To,string mail_Password,string mail_Subject,string mail_Message)
        {
            objMailAddress = new MailAddress(mail_From);
            System.Net.NetworkCredential objNetworkCredential = new System.Net.NetworkCredential(mail_From, mail_Password);
            objSmtpClient.UseDefaultCredentials = false;
            objSmtpClient.Credentials = objNetworkCredential;
            objMailMessage.From = objMailAddress;
            objMailMessage.Subject = mail_Subject;
            objMailMessage.Body = mail_Message;
            objMailMessage.IsBodyHtml = false;
            objMailMessage.To.Add(mail_To);
            try
            {
                objSmtpClient.Send(objMailMessage);
                    return true;
            }
            catch (Exception e)
            {
                return false; 
            }
        }
    }
}

make necessary changes for the above code.
 
Share this answer
 
v2
Comments
leocode7 21-Jan-14 17:09pm    
dear friend how I can do this with Visual Studio 2003??

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