Click here to Skip to main content
16,016,901 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi,

i am stuck in weird issue , i am trying to send variable value (which i have
calculated in .cs file )to various people through mail which is also send from code behind.

Is it possible ? if yes can you please tell me how ??


Thanks
PArth
Posted
Comments
Sergey Alexandrovich Kryukov 5-Jun-12 1:16am    
And how it could be a problem? I just don't understand. When you sent a-mail somehow, you already use some variable(s) you have calculated in C#, so what's the difference?
--SA

Thanks............................................................
 
Share this answer
 
C#
try
            {
                MailMessage mail = new MailMessage();
                mail.To.Add("anzaman_edi@yahoo.com");
                mail.To.Add("shi01715@yahoo.com");
                mail.From = new MailAddress("shishir64092@gmail.com");
                mail.Subject = "Send Email by asp.net code using google or gmail smtp server";
 
                string Body = "Hi"+USERNAME+ ", I am testing Email function in asp.net" +
                              "using google or gmail smtp server";
                mail.Body = Body;
 
                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address  
                smtp.Credentials = new System.Net.NetworkCredential
                     ("shishir64092@gmail.com", "abcdef");
                //Or your Smtp Email ID and Password  
                smtp.EnableSsl = true;
                smtp.Send(mail);
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
            }

in your mail body you can set your params!
 
Share this answer
 
Comments
VJ Reddy 4-Jun-12 23:34pm    
Good answer. 5!
Yes.

The basic email is simple: Sending an Email in C# with or without attachments: generic routine.[^]

Within that, you can send the variable value as text, or you could serialize the value (using for example the XmlSerializer[^]) and send it as an attachment if you need to be able to computer read it rather than human.
 
Share this answer
 
Comments
VJ Reddy 4-Jun-12 23:34pm    
Good answer. 5!

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