Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Automatic download attachment from emails

Automatic download attachment from emails

Scheduled Pinned Locked Moved C#
csharpdatabase
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spankyleo123
    wrote on last edited by
    #1

    Hello people, My client wants to have an app which will automatically download excel 2003 attachments from emails and store it into the database. At the moment I have designed an app in C# which reads excel sheet by browsing to it from the local machine and then displays contents into the GUI. Is there any way in which I can automate this process.. Cheers!

    C M 2 Replies Last reply
    0
    • S spankyleo123

      Hello people, My client wants to have an app which will automatically download excel 2003 attachments from emails and store it into the database. At the moment I have designed an app in C# which reads excel sheet by browsing to it from the local machine and then displays contents into the GUI. Is there any way in which I can automate this process.. Cheers!

      C Offline
      C Offline
      c0ax_lx
      wrote on last edited by
      #2

      Here's A POP3 Client in C# .NET[^] a good link to get you started on the emails. look at the last codeblock for attachment retrieval.

      If it' stuck, DO NOT pull harder!

      1 Reply Last reply
      0
      • S spankyleo123

        Hello people, My client wants to have an app which will automatically download excel 2003 attachments from emails and store it into the database. At the moment I have designed an app in C# which reads excel sheet by browsing to it from the local machine and then displays contents into the GUI. Is there any way in which I can automate this process.. Cheers!

        M Offline
        M Offline
        moon_stick
        wrote on last edited by
        #3

        If you're using Outlook you could write a small add-in and hook onto the mail received event. This would then start a process to check the received message, check for attachments and do any further processing required. I assume you're talking about holding the actual file in the database - it might be a better idea to save the files on a drive and write a reference to the path in a table somewhere.

        It definitely isn't definatley

        S 1 Reply Last reply
        0
        • M moon_stick

          If you're using Outlook you could write a small add-in and hook onto the mail received event. This would then start a process to check the received message, check for attachments and do any further processing required. I assume you're talking about holding the actual file in the database - it might be a better idea to save the files on a drive and write a reference to the path in a table somewhere.

          It definitely isn't definatley

          S Offline
          S Offline
          spankyleo123
          wrote on last edited by
          #4

          Yea am using outlook 2003 to receive emails from clients. The emails contain the Excel sheet with a fixed format. Could u elaborate on how it would be possible to write a reference to Outlook using C#, so that application click even can check for new attachments and download it.

          M 2 Replies Last reply
          0
          • S spankyleo123

            Yea am using outlook 2003 to receive emails from clients. The emails contain the Excel sheet with a fixed format. Could u elaborate on how it would be possible to write a reference to Outlook using C#, so that application click even can check for new attachments and download it.

            M Offline
            M Offline
            moon_stick
            wrote on last edited by
            #5

            It's a couple of years since I've done this and don't appear to have anything directly relevant to hand. However, you'll be best doing some research into Visual Studio Tools for Office (VSTO - there's some good articles here[^]) as well as the Outlook object model (try here[^]). In summary, you'll create an Add-in for Outlook using VSTO. This add-in will register as a listener with the NewMailEx event (mail received) and once the event is fired, the add-in will examine the new mail to determine whether or not is has any attachments and if any of these are excel documents. From here the rest of your task should be fairly trivial; either you'll copy the file to a folder somewhere and execute a stored procedure to write an entry into a database table somewhere or you'll stream the file directly into the database (depending on what method of storage you use). A quick google will bring up a stack of articles; I remember in the past having some trouble deploying Office 2003 add-ins but think they were mostly resolved by ensuring that VSTO was installed on the client machine (free download from MS[^]) Sorry I don't have anything more specific but with a little bit of research you should be able to find your way. HTH

            It definitely isn't definatley

            1 Reply Last reply
            0
            • S spankyleo123

              Yea am using outlook 2003 to receive emails from clients. The emails contain the Excel sheet with a fixed format. Could u elaborate on how it would be possible to write a reference to Outlook using C#, so that application click even can check for new attachments and download it.

              M Offline
              M Offline
              moon_stick
              wrote on last edited by
              #6

              I've just re-read this; it sound like you're wanted to copy the contents of the excel file into a database table. If you know that the format of the file is going to be identical each time, I'd suggest creating a DTS package using integration services and executing this, passing in the name of the file as a variable. If it's not identical you might struggle - it's non-trivial at any rate.

              It definitely isn't definatley

              S 1 Reply Last reply
              0
              • M moon_stick

                I've just re-read this; it sound like you're wanted to copy the contents of the excel file into a database table. If you know that the format of the file is going to be identical each time, I'd suggest creating a DTS package using integration services and executing this, passing in the name of the file as a variable. If it's not identical you might struggle - it's non-trivial at any rate.

                It definitely isn't definatley

                S Offline
                S Offline
                spankyleo123
                wrote on last edited by
                #7

                The name of the Excel File varies, but the sheet has fixed columns & column names. Data appearing in the column varies.

                M 1 Reply Last reply
                0
                • S spankyleo123

                  The name of the Excel File varies, but the sheet has fixed columns & column names. Data appearing in the column varies.

                  M Offline
                  M Offline
                  moon_stick
                  wrote on last edited by
                  #8

                  In which case you should be able to build a simple DTS package and execute it from within the add-in. I've not really got enough room to explain here but there's plenty of articles and the SSIS newsgroups have some pretty comprehensive examples.

                  It definitely isn't definatley

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups