Hi all,
Is there any way to send an email with an attached file from a driver Qaction? I have managed to create a script to send the email an execute that script it from a QAction but it would be necessary to perform the whole process from the Qaction. Can you help me, please?
Thanks in advance.
Hi Pilar,
You could do it like below:
MailMessage mail = new MailMessage("info@skyline.be", "pilar@dojo.be");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "mail.server.com";
mail.Subject = "subject";
mail.Body = "body";
mail.IsBodyHtml = true;string attachementPath = @"c:\server temp folder\test.txt";
if (File.Exists(attachementPath))
{
Attachment attachment;
attachment = new Attachment(attachementPath);
mail.Attachments.Add(attachment);
}client.Send(mail);
mail.Dispose();