Iam using below code for sending a mail, but its not storing in my sent mail option, how can i see that one in sentmail and how can i find that mail size?
Expand|Select|Wrap|Line Numbers
- MailMessage msg = new MailMessage();
- msg.From = new MailAddress((TextBox1.Text));
- msg.To.Add((TextBox4.Text));
- if (FileUpload1.HasFile)
- {
- string fileName =FileUpload1.PostedFile.FileName;
- Attachment myAttachment =
- new Attachment(FileUpload1.FileContent, fileName);
- msg.Attachments.Add(myAttachment);
- }
- msg.Subject = TextBox2.Text.ToString();
- msg.Body = TextBox3.Text.ToString();
- try
- {
- SmtpClient smtp = new SmtpClient("smtp.gmail.com",587);
- // SmtpClient smtp = new SmtpClient("smtp.mailserver.com");
- smtp.EnableSsl = true;
- smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
- NetworkCredential myCreds = new NetworkCredential("gmail id", "gmail password");
- smtp.Credentials = myCreds;
- smtp.Send(msg);
- Label4.Visible = true;
- Label4.Text = "Mail Sent Successfully";
- }
- catch (Exception exc)
- {
- Label4.Visible = true;
- Label4.Text = "Failure Message: " + exc.Message.ToString();
- }