This is a migrated thread and some comments may be shown as answers.

excel attachment via email

3 Answers 37 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Balaram
Top achievements
Rank 1
Balaram asked on 12 Jun 2012, 05:24 AM
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

3 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 12 Jun 2012, 02:16 PM
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
0
Jonas
Top achievements
Rank 2
answered on 13 Jun 2012, 08:33 AM
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);
}
}
0
Cody
Telerik team
answered on 13 Jun 2012, 06:01 PM
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
Tags
General Discussions
Asked by
Balaram
Top achievements
Rank 1
Answers by
Cody
Telerik team
Jonas
Top achievements
Rank 2
Share this question
or