Is there a way to schedule a mail to be sent each day on a specific time with a file in the UNC path.

Posted on 2008-11-06
Last Modified: 2012-05-05

Is there a way to schedule a mail to be sent each day on a specific time with a file in the UNC path.
This file is daily changed . Is there any way to each day send a mail with this file as attachment to some users.

its a xlsm file which has to be mailed.

Question by:bsharath
    LVL 5

    Accepted Solution

    Try something in Vb script in the same UNC path
    Dim objOutl
    Set objOutl = CreateObject("Outlook.Application")
    Set objMailItem = objOutl.CreateItem(olMailItem)
    'comment the next line if you do not want to see the outlook window
    strEmailAddr  = ""
    objMailItem.Recipients.Add strEmailAddr
    objMailItem.Body = "Hi"
    objMailItem.Attachments.Add "file.xml"
    Set objMailItem = nothing
    Set objOutl = nothing

    Open in new window

    LVL 11

    Author Comment

    I get this

    I have the file name mentioned and have the vbs in the same folder where the file is
    Windows Script Host
    Script:      D:\Mail.vbs
    Line:      9
    Char:      1
    Error:      Cannot find this file. Verify the path and file name are correct.
    Code:      80070002
    Source:       Microsoft Office Outlook

    LVL 4

    Assisted Solution

    Line 9 has to have the full path of the file your attaching.   However I think it doesn't support UNC.   that being said, You have to map out the folder to a drive, which you can do in VBS as well before you run the above, then disconnect the drive before exiting.

    However, this script does email, but you have to use (AT) command line to schedule it, or you can manually do it through Windows Scheduler.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now