excel attachment via email

4 posts, 0 answers
  1. Balaram
    Balaram avatar
    2 posts
    Member since:
    May 2012

    Posted 12 Jun 2012 Link to this post

    Hi,

    I am exporting my automated results to an excel sheet saved on my desktop. I would like to send the excel sheet as an attachment to some xyz email id.(xyz@gmail.com). Could you please let me know if sending an excel file as an attachemnt to an email id is possible using test studio? If yes could you please help me using c#.net.

    Regards,
    Balaram
  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 12 Jun 2012 Link to this post

    Hi Balaram,

    I suspect to do what you want requires an automated way of exporting the results to an Excel file. Currently there is no automated way to do this i.e. we do not have an API function to export the results. You will have to do this manually. Since the export must be done manually it will probably be better to manually send the email as well.

    I'm sure there's lots of code samples available on the Internet showing how to send email with attachments. Since this function does not directly involve using Test Studio, such functionality is outside of Test Studio support. We will not be able to create a code sample for you to do this.

    Greetings,
    Cody
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Jonas
    Jonas avatar
    20 posts
    Member since:
    Jun 2012

    Posted 13 Jun 2012 Link to this post

    Hello Balaram,

    I've made this in my project. This is the code that i'm using.

    public class Email
    {
    public
    Email(string recieverAdress)
    {
        mail = new MailMessage("sender@domain.com", recieverAdress);
    }
     
    private MailMessage mail;
    private SmtpClient smtpClient = new SmtpClient("smtp.domain.com", port);
    private NetworkCredential credential = new NetworkCredential("username", "password");
     
    public void SendMail(string subject, string textInBody)
    {
        mail.Subject = DateTime.Now + " " + subject;
        mail.Body = textInBody;
        smtpClient.Credentials = credential;
        smtpClient.Send(mail);
    }
     
    public void SendMail(string subject, string textInBody, string attachment)
    {
        mail.Attachments.Add(new Attachment(attachment));
        SendMail(subject, textInBody);
    }
    }
  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 13 Jun 2012 Link to this post

    Hi Jonas,

    Thank you for your assistance to Balaram. I've granted you some additional Telerik Points as compensation.

    All the best,
    Cody
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!