Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2004
    Posts
    3

    Unanswered: Automated import of XLS to SQL

    I have a customer who insists on emailing an excel spreadsheet to me to be uploaded to a sql database. I came across a script at one point that laid out how I would script this out. Basically it was in parts, 1. open email program and get attachment. 2.After saving attachment closing email program in order to be used the next day or next time an attachment was sent. 3. import the attached spreadsheet into SQL database. I would also like to be able to schedule this to run with the built in Windows 2000 scheduler.

    Can anyone help me out on this one??

    Thanks,
    Will

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    What email application are you using ... Also, you want to do all these steps within sql as a job ?

  3. #3
    Join Date
    Jan 2004
    Posts
    3
    Currently I have it set up with the pre-security patched version of Outlook 2k. I would love to have it set up as one job that launches each morning at 8am. Currently I have a script that I run manually that opens Outlook, saves the attachment, moves the message to a subfolder, sends a confirmation email then closes Outlook. It is a wsf file (see below) but when I try to run it as a scheduled task it doesn't do a darn thing.

    Code:
    <job>
    <script language="VBScript">
    dim WshShell
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set objOL = WScript.CreateObject ("Outlook.Application")
    Set MAPI = objOL.GetNamespace("MAPI")
    Set myStore = MAPI.Folders("Mailbox - Tunisia Information")
    Set Folder = myStore.Folders("Inbox")
    ' Open up the Processed Folder under the inbox
    Set DestFldr = Folder.Folders("Processed")
    For Each myItem In Folder.Items
    For Each att In myItem.Attachments
    att.SaveAsFile "\\naslc03\data\TunisiaProdData\" & att.Filename
    Next
    ' Move the Mail to DestFldr
    myItem.Move DestFldr
    Next

    ' Create mail message.
    Set olMailMessage = objOl.CreateItem(olMailItem)
    With olMailMessage
    Set olRecipient = .Recipients.Add("TunisiaProdData@pioneernrc.com")
    .Subject = "Tunisia Attachment"
    .Body = "The Tunisia email message was created was processed" _
    & " and the attachment was successfully saved to the S: Drive."
    .Send
    End With
    Set olMailMessage = Nothing

    objOL.quit


    </script>
    </job>

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    Good - You can try to implement this within dts, using the activex script task. Once this task is complete, you can import the excel file. The easiest way to set this up if you have not worked with dts before, is to go to Enterprise Manager -> Databases -> The database you want to import into -> tables. Right click on tables -> All tasks -> Import Data. Follow the instructions - making sure at the end to save it. When you have saved it, you can modify the package under Data Transformation Services -> Local Packages. Open your package in design mode and create an activex script task. Insert your code into that task and run that step to see if it will function properly.

  5. #5
    Join Date
    Jan 2004
    Posts
    3
    Thanks I will give that a shot and let you know.

  6. #6
    Join Date
    Feb 2002
    Posts
    2,232
    If adding it as an activex script does not work, you can still keep the rest of the package (the excel import). When you create a job based on this package, you can add a step that will execute an operating system command (which would be your script).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •