Kaseya Community

Email an attachment

  • Anyone figure out how to email an attachment from a script?

    I'm running a robocopy of some DB backups to automate monthly task. Currently I have robocopy putting the results to a text file and then I email the contents of the text file. The email comes through as HTML formatted and the UNC path's of the files end up being translated as URL's and it's very annoying.

    It would be easier to email the log file, but I don't see that as an option.

    Any help would be appreciated.
    Thanks!

    Legacy Forum Name: Email an attachment,
    Legacy Posted By Username: syscal
  • syscal
    Anyone figure out how to email an attachment from a script?

    I'm running a robocopy of some DB backups to automate monthly task. Currently I have robocopy putting the results to a text file and then I email the contents of the text file. The email comes through as HTML formatted and the UNC path's of the files end up being translated as URL's and it's very annoying.

    It would be easier to email the log file, but I don't see that as an option.

    Any help would be appreciated.
    Thanks!



    Well, it depends, do u have smtp server/cdo on the server? Do u want to send email directly to remote smtp host?
    I would just create console program in .NET (use system.web.mail ) , that accepts mail receiver , subject ,body and attachment file as input parameter.
    Example, i would do like that:

    MailMessage mail = new MailMessage()
    mail.To = "mailto:friendname@websitename.com">friendname@websitename.com";mail.From = "mailto:yourname@websitename.com">yourname@websitename.com";mail.Subject = "Mail Subject";mail.Body = "Mail Body";Adding attachments
    For adding attchments create an object for MailAttchment class.
    MailAttachment att = new MailAttachment(filename).
    Then add this mail attachment object to MailMessage object. For that use mail.AddAttchment(att).

    Or VBS way
    http://www.paulsadowski.com/WSH/cdo.htm

    Hope this helps ...
    Rudi, Networking Plus

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: rudi