mail pdf automatically that i have generated...
i want to mail a pdf that i havce generated.. i.e., if i clicked on a button than pdf will send automatically with its attachment.. plz provide solution.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rafnas T PPosted Feb 10, 2017, 5:21 AM
{
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();
message.From = new MailAddress("FromMailAddress");
message.To.Add(new MailAddress("ToMailAddress"));
message.Subject = "Test";
message.IsBodyHtml = true; //set true if you want to set body string as html
message.Body = " ";\\Body string
string attachmentFilename = @"E:\tt.pdf"; //FullFilePathWithExtension
if (attachmentFilename != null)
message.Attachments.Add(new Attachment(attachmentFilename)); //Attach here
smtp.Port = 587;
smtp.Host = "smtp.gmail.com"; //for gmail host
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("FromMailAddress", "password");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);
}
catch (Exception)
{ }
Nitin SontakkePosted Feb 10, 2017, 12:13 AM
parul jainPosted Feb 9, 2017, 11:41 PM
Nitin SontakkePosted Feb 9, 2017, 8:15 AM