Kaseya Community

Looking for method to send an email with a file attachment with the file coming from the agent

This question has suggested answer(s)

We want to have a procedure run on a nightly basis that will create a report from a local database on a managed machine. Once the report is created on that machine, we need a method to send an email to a small group of recipients. In the email, we want to attach the report. 

I could not find any native tools within the VSA to do this. I reached out to my rep for assist and he was told that the current design of the VSA (we are on 9.4), does not support this.

Anyone have ideas to make this happen?

Thanks, Steve

All Replies
  • Power Automate and Flow.

    Kick report to a monitored folder. Flow can copy to onedrive. Onedrive can then use flow to email it with a service account.

    You can also set onedrive to sharepoint path redundancy if desired.

    Depending on the reporting engine and database you can probably enable smtp in it, and have it email via a domain service account.

    Drinking Microsoft Kool-Aid is a lot more fun today than historically.

  • This is just wild talk! Pretty neat idea, really. However, in this use case these systems are a form of self-service kiosk (not a "normal desktop") and the Microsoft tools you described are not available on them. I might checkout your suggestion on my own workstation though. Thanks!

  • yust use a azure functions who receives some parameters ( HTTP POST )




    binary blob

    blob mime type

    and send the mail in C# ...

    easy !

  • If you have a service Admin account in the clients o365 tenancy, or if the email of the power user wanting this report has o365 pro plus, it is very simple. these are available by logging into office365.com and just clicking flow. As long as the report drops to the monitored path, or is emailed via a single monitored pre-defined service account, everything else will happen automatically.

  • I used this a while ago for a very quick and dry solution, adjust and add logic to your liking. You will need to review the help file for MailSend at https://github.com/muquit/mailsend

    <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
    <Procedure name="Attach file using MailSend" treePres="3" id="2086665364" folderId="454103883567314" treeFullPath="myProcedures - ">
    <Body description="using https://github.com/muquit/mailsend">
    <Statement name="WriteFile" continueOnFail="true" osType="Windows">
    <Parameter xsi:type="StringParameter" name="Path" value="c:\kworking\mailsend.exe"/>
    <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\mailsend.exe"/>
    <Parameter xsi:type="BooleanParameter" name="DeleteAfter" value="False"/>
    <Statement name="GetVariable" continueOnFail="false" osType="Windows">
    <Parameter xsi:type="EnumParameter" name="VariableType" value="MachineGroupID"/>
    <Parameter xsi:type="StringParameter" name="SourceContent" value=""/>
    <Parameter xsi:type="StringParameter" name="VariableName" value="mach"/>
    <Statement name="GetVariable" continueOnFail="false" osType="Windows">
    <Parameter xsi:type="EnumParameter" name="VariableType" value="Prompt"/>
    <Parameter xsi:type="StringParameter" name="SourceContent" value="Please enter the file name (full path) of the file being attached (ie c:\kworking\test.txt)."/>
    <Parameter xsi:type="StringParameter" name="VariableName" value="file"/>
    <Statement name="GetVariable" continueOnFail="false" osType="Windows">
    <Parameter xsi:type="EnumParameter" name="VariableType" value="Prompt"/>
    <Parameter xsi:type="StringParameter" name="SourceContent" value="Please enter subject"/>
    <Parameter xsi:type="StringParameter" name="VariableName" value="subject"/>
    <Statement name="WriteScriptLogEntry" continueOnFail="false" osType="Windows">
    <Parameter xsi:type="StringParameter" name="Comment" value="c:\kworking\mailsend.exe -smtp <<SMTP RELAY SERVER>> -port <<PORT#>> -t #adminDefaults.adminEmail# -f <<RECIPIENT>> -sub "#subject#_#mach#" -attach "#file#" -v -log c:\kworking\mailsend.log"/>
    <Statement name="PauseScript" continueOnFail="false" osType="Windows">
    <Parameter xsi:type="IntegerParameter" name="Seconds" value="10"/>
    <Statement name="GetFile" continueOnFail="false" osType="None">
    <Parameter xsi:type="StringParameter" name="RemoteFileName" value="c:\kworking\mailsend.log"/>
    <Parameter xsi:type="StringParameter" name="KServerFileName" value="Mailsend.Log"/>
    <Parameter xsi:type="EnumParameter" name="Action" value="OverwriteNoAlert"/>

  • Thanks. I am looking into this now. Steve