Answer 4
Thank you very much.
Yes you are right.
Actually the scenario is that it is my college project so I can not get any web-hosting facility. So what I did is that I created an email account in GMail and have sent email to given email address(es). I have added the credentials of that newly created email address into web.config.
Here it is :
<system.net>
<mailSettings>
<smtp>
<network host="smtp.gmail.com" port="25" userName="my.email.address@gmail.com" password="mypassword"/>
</smtp>
</mailSettings>
</system.net>
And here is the C# script :
Document PdfDocument = new Document(iTextSharp.text.PageSize.A4, 20, 20, 20, 20);
PdfWriter.GetInstance(PdfDocument , new FileStream("filename" , FileMode.Create));
PdfDocument.Open();
PdfDocument.Add(new Paragraph("some data"));
PdfDocument.Close();
string file = "filename";
Attachment data = new Attachment(file , MediaTypeNames.Application.Octet);
ContentDisposition disposition = data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(file);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
MailMessage EMail = new MailMessage();
EMail.To.Add("toemailaddress");
EMail.From = new MailAddress("fromemailaddress");
EMail.Subject = "Leave Application";
EMail.Body = "Check out the attachment!";
EMail.Attachments.Add(data);
EMail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
Smtp.EnableSsl = true;
try {
Smtp.Send(EMail);
} catch (Exception) {
}
And it is working.
Can you please tell em how can I encrypt the password written in web.config?
Thank you.