Click here to Skip to main content
15,922,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear all

i have a matrimonial website and i want to send mail to user.
in email body i want to send some graphic photo.
example:- times job, monster send to mail for user.
please help me about it.
Posted

Hi ,
Check this link
www.codeproject.com/Answers/367746/sending-emails-in-asp-net[^]
Best Regards
M.Mitwalli
 
Share this answer
 
C#
protected void SendMail(object sender, EventArgs e)
    {

            System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress(@ConfigurationSettings.AppSettings["EmailFrom"]);
            smtpClient.Host = @ConfigurationSettings.AppSettings["MailServerName"];
            smtpClient.Port = Convert.ToInt32(@ConfigurationSettings.AppSettings["Port"]);
            message.From = fromAddress;
            message.To.Add(@ConfigurationSettings.AppSettings["EmailTo"]);
            message.Subject = @ConfigurationSettings.AppSettings["EmailSubject"];
            message.IsBodyHtml = false;
            message.Body = "<html><body>ANY TEXT HERE....<br>" +  "<img src=\"Image\Test.jpeg"> </body></html>";
            smtpClient.Send(message);
        }
        finally
        {
            sw.Close();
        }
    }

  <appSettings>
  <connectionStrings>

    <add key="Port" value="587"/>
    <add key="MailServerName" value="smtp.gmail.com"/>
    <add key="EmailFrom" value="emailfrom@gmail.com"/>
    <add key="EmailPassword" value="pass@123"/>
    <add key="EmailTo" value="emailto@gmail.com"/>
    <add key="EmailSubject" value="My Email Subject"/>

  </appSettings>
  <connectionStrings/>
 
Share this answer
 
try this

MailAddress mailfrom = new MailAddress ( "frommail@gmail.com" );
           MailAddress mailto = new MailAddress ( "tomail@gmail.com" );
           MailMessage newmsg = new MailMessage ( mailfrom, mailto );
           newmsg.Subject = "Subject of Email";
           newmsg.Body = "Body(message) of email";
           ////For File Attachment, more file can also be attached
           Attachment att = new Attachment ( "G:\\code.txt" );
           newmsg.Attachments.Add ( att );
           SmtpClient smtps = new SmtpClient ( "smtp.gmail.com", 587 );
           smtps.UseDefaultCredentials = false;
           smtps.Credentials = new NetworkCredential ( "urmail@gmail.com", "urpwd" );
           smtps.EnableSsl = true;
           smtps.Send ( newmsg );
 
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