Hi everyone,
We generate a CSV file everyday at 8 am with an Automation script. I would like to send it to some collegue internally via email.
I know that it is easy to do with Reports directly in Dataminer but I wonder how I could do that with a file that is stored on the server ?
Can you help me with that ?
Please take note that the SMTP server is already configured on the server so it is ready to send emails.
Thanks a lot,
Hi Gautier,
It should be possible to send an email with an attachment via automation script. Could you try adding the code below in your automation script?
In the example below, the file is located in the DMA (C:\Skyline DataMiner\Documents\Reports\CPUReport.csv)
string CSVPath = @"C:\Skyline DataMiner\Documents\Reports\CPUReport.csv"; EmailAttachment myAttachement = new EmailAttachment("CPUReport.csv", File.ReadAllBytes(CSVPath)); SendEmailMessage myMessage = new SendEmailMessage() { Attachments = new EmailAttachment[1] { myAttachement }, From = "Reports@DataMiner.be", To = "your.email@skyline.be", Subject = "CPU Report", Body = "Find attached the CPU CSV Report" }; engine.SendSLNetMessage(myMessage);
Hi Gautier,
As Daniela mentioned, you need to include the following namespace:
using Skyline.DataMiner.Net.Messages;
Please find below a full example:
++++++++++++++++++++++
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using Skyline.DataMiner.Automation;
using Skyline.DataMiner.Net.Messages;
class Script
{
public void Run(Engine engine)
{
string CSVPath = @”C:Skyline DataMinerDocumentsDMA_COMMON_DOCUMENTSTEST_REPORTStestReport.csv”;
EmailAttachment myAttachement = new EmailAttachment(“CPUReport.csv”, File.ReadAllBytes(CSVPath));
SendEmailMessage myMessage = new SendEmailMessage()
{
Attachments = new EmailAttachment[1] { myAttachement },
From = “Reports@DataMiner.be”,
To = “your.email@skyline.be”,
Subject = “CPU Report”,
Body = “Find attached the test report”
};
engine.SendSLNetMessage(myMessage);
}
}
++++++++++++++++++++++++++++++++
Disclaimer about Skyline.DataMiner.Net.Messages:
Note that this is an internal call and we do not recommend using this, as it is not officially supported and we cannot guarantee that it will still work in the future. As a rule, you should avoid using SLNet calls, as these are subject to change without notice. We recommend to instead always use the correct UI or automation options provided in DataMiner Automation or through our web API.
Thanks a lot Miguel !
I gave it a try but I have some errors. Do I need to include some dlls ?
Thanks