word automation vb.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    #1

    word automation vb.net

    I've been building an application that will merge fields in a text file with
    a word template, save the resulting word file out to the user's hard drive,
    and then email the file as an attachment.

    The problem I'm having is that I can't delete the word file I saved at the
    end of the process due to the file being locked by the email process. It
    appears to take longer than the code takes to complete due to virus checking
    software that intercepts the mail before releasing it (at least that's what
    I've narrowed it down to).

    I don't want to leave the file around after the code has completed. And I
    don't think I want to hold up the completion of the code process until the
    email gets sent in case the email process takes longer on some machines than
    others.

    I'm not sure if there is a better way to handle the attachment in the code
    so I don't have to save a file to the user's desktop. Or if I can use a
    deattach process that I can trigger from code to delete the file later. Or
    something else.

    I've attached a snippet of the code below:

    Thanks
    Steve

    ------------

    WordDoc.SaveAs( sSaveFileName)
    Do While Not WordDoc.Saved
    Application.DoE vents()
    Loop
    WordDoc.Close(W ord.WdSaveOptio ns.wdDoNotSaveC hanges)

    ' Email the Saved Merge Document.

    Dim Fromaddress As New MailAddress("fr omaddress")
    Dim Toaddress As New MailAddress("to address")
    Dim myMail As New MailMessage(Fro maddress, ToAddress)
    myMail.Subject = "test"
    Dim AttachmentFile As Attachment = New Attachment(sSav eFileName)
    myMail.Attachme nts.Add(Attachm entFile)
    myMail.Priority = MailPriority.Hi gh
    Dim client As New SmtpClient
    client.Host = "hostaddres s"
    client.Send(myM ail)

    ' Release the references.

    WordMailMerge = Nothing
    WordDoc = Nothing
    WordApp = Nothing

    ' Delete the temporary files.

    System.IO.File. Delete(sSaveFil eName)




  • susiedba@hotmail.com

    #2
    Re: word automation vb.net

    sorry bud it is as simple as Word Automation

    but of course; Microsoft doesn't support vb6 anymore so you're shit out
    of luck

    I would build a time machine and go back to the 90s and never bother
    with VB.NOT

    -Susie, DBA



    Steve wrote:
    I've been building an application that will merge fields in a text file with
    a word template, save the resulting word file out to the user's hard drive,
    and then email the file as an attachment.
    >
    The problem I'm having is that I can't delete the word file I saved at the
    end of the process due to the file being locked by the email process. It
    appears to take longer than the code takes to complete due to virus checking
    software that intercepts the mail before releasing it (at least that's what
    I've narrowed it down to).
    >
    I don't want to leave the file around after the code has completed. And I
    don't think I want to hold up the completion of the code process until the
    email gets sent in case the email process takes longer on some machines than
    others.
    >
    I'm not sure if there is a better way to handle the attachment in the code
    so I don't have to save a file to the user's desktop. Or if I can use a
    deattach process that I can trigger from code to delete the file later. Or
    something else.
    >
    I've attached a snippet of the code below:
    >
    Thanks
    Steve
    >
    ------------
    >
    WordDoc.SaveAs( sSaveFileName)
    Do While Not WordDoc.Saved
    Application.DoE vents()
    Loop
    WordDoc.Close(W ord.WdSaveOptio ns.wdDoNotSaveC hanges)
    >
    ' Email the Saved Merge Document.
    >
    Dim Fromaddress As New MailAddress("fr omaddress")
    Dim Toaddress As New MailAddress("to address")
    Dim myMail As New MailMessage(Fro maddress, ToAddress)
    myMail.Subject = "test"
    Dim AttachmentFile As Attachment = New Attachment(sSav eFileName)
    myMail.Attachme nts.Add(Attachm entFile)
    myMail.Priority = MailPriority.Hi gh
    Dim client As New SmtpClient
    client.Host = "hostaddres s"
    client.Send(myM ail)
    >
    ' Release the references.
    >
    WordMailMerge = Nothing
    WordDoc = Nothing
    WordApp = Nothing
    >
    ' Delete the temporary files.
    >
    System.IO.File. Delete(sSaveFil eName)

    Comment

    • BK

      #3
      Re: word automation vb.net

      Disregard "Susie", he/she/it suffers from split personalities and none
      of them are real programmers....

      I think you want to look at the SmtpClient.Send Completed documentation,
      that's what you are missing.

      Comment

      • The Grim Reaper

        #4
        Re: word automation vb.net

        You need a WordDoc.Quit after your WordDoc.Close.
        _______________ _______________ ___
        The Grim Reaper

        "Steve" <s.arndt@comcas t.netwrote in message
        news:eOB0SXmEHH A.2356@TK2MSFTN GP03.phx.gbl...
        I've been building an application that will merge fields in a text file
        with
        a word template, save the resulting word file out to the user's hard
        drive,
        and then email the file as an attachment.
        >
        The problem I'm having is that I can't delete the word file I saved at the
        end of the process due to the file being locked by the email process. It
        appears to take longer than the code takes to complete due to virus
        checking
        software that intercepts the mail before releasing it (at least that's
        what
        I've narrowed it down to).
        >
        I don't want to leave the file around after the code has completed. And I
        don't think I want to hold up the completion of the code process until the
        email gets sent in case the email process takes longer on some machines
        than
        others.
        >
        I'm not sure if there is a better way to handle the attachment in the code
        so I don't have to save a file to the user's desktop. Or if I can use a
        deattach process that I can trigger from code to delete the file later.
        Or
        something else.
        >
        I've attached a snippet of the code below:
        >
        Thanks
        Steve
        >
        ------------
        >
        WordDoc.SaveAs( sSaveFileName)
        Do While Not WordDoc.Saved
        Application.DoE vents()
        Loop
        WordDoc.Close(W ord.WdSaveOptio ns.wdDoNotSaveC hanges)
        >
        ' Email the Saved Merge Document.
        >
        Dim Fromaddress As New MailAddress("fr omaddress")
        Dim Toaddress As New MailAddress("to address")
        Dim myMail As New MailMessage(Fro maddress, ToAddress)
        myMail.Subject = "test"
        Dim AttachmentFile As Attachment = New Attachment(sSav eFileName)
        myMail.Attachme nts.Add(Attachm entFile)
        myMail.Priority = MailPriority.Hi gh
        Dim client As New SmtpClient
        client.Host = "hostaddres s"
        client.Send(myM ail)
        >
        ' Release the references.
        >
        WordMailMerge = Nothing
        WordDoc = Nothing
        WordApp = Nothing
        >
        ' Delete the temporary files.
        >
        System.IO.File. Delete(sSaveFil eName)
        >
        >
        >
        >

        Comment

        • Steve

          #5
          Re: word automation vb.net

          But this will close the word application which the user running the program
          will want to keep open for printing the active document. I am trying to
          blindly send an email (legit) during the process.

          Steve

          "The Grim Reaper" <grim_reaper@RE MOVEbtopenworld .comwrote in message
          news:-NidnWSQ689l__bY RVnytQ@bt.com.. .
          You need a WordDoc.Quit after your WordDoc.Close.
          _______________ _______________ ___
          The Grim Reaper
          >
          "Steve" <s.arndt@comcas t.netwrote in message
          news:eOB0SXmEHH A.2356@TK2MSFTN GP03.phx.gbl...
          I've been building an application that will merge fields in a text file
          with
          a word template, save the resulting word file out to the user's hard
          drive,
          and then email the file as an attachment.

          The problem I'm having is that I can't delete the word file I saved at
          the
          end of the process due to the file being locked by the email process.
          It
          appears to take longer than the code takes to complete due to virus
          checking
          software that intercepts the mail before releasing it (at least that's
          what
          I've narrowed it down to).

          I don't want to leave the file around after the code has completed. And
          I
          don't think I want to hold up the completion of the code process until
          the
          email gets sent in case the email process takes longer on some machines
          than
          others.

          I'm not sure if there is a better way to handle the attachment in the
          code
          so I don't have to save a file to the user's desktop. Or if I can use a
          deattach process that I can trigger from code to delete the file later.
          Or
          something else.

          I've attached a snippet of the code below:

          Thanks
          Steve

          ------------

          WordDoc.SaveAs( sSaveFileName)
          Do While Not WordDoc.Saved
          Application.DoE vents()
          Loop
          WordDoc.Close(W ord.WdSaveOptio ns.wdDoNotSaveC hanges)

          ' Email the Saved Merge Document.

          Dim Fromaddress As New MailAddress("fr omaddress")
          Dim Toaddress As New MailAddress("to address")
          Dim myMail As New MailMessage(Fro maddress, ToAddress)
          myMail.Subject = "test"
          Dim AttachmentFile As Attachment = New Attachment(sSav eFileName)
          myMail.Attachme nts.Add(Attachm entFile)
          myMail.Priority = MailPriority.Hi gh
          Dim client As New SmtpClient
          client.Host = "hostaddres s"
          client.Send(myM ail)

          ' Release the references.

          WordMailMerge = Nothing
          WordDoc = Nothing
          WordApp = Nothing

          ' Delete the temporary files.

          System.IO.File. Delete(sSaveFil eName)


          >
          >

          Comment

          • RobinS

            #6
            Re: word automation vb.net

            Could you save a separate copy as a temp file and send that
            in the e-mail and then delete it?

            Robin S.
            --------------------------
            "Steve" <s.arndt@comcas t.netwrote in message
            news:%23jnNTInE HHA.4256@TK2MSF TNGP04.phx.gbl. ..
            But this will close the word application which the user running the
            program
            will want to keep open for printing the active document. I am trying to
            blindly send an email (legit) during the process.
            >
            Steve
            >
            "The Grim Reaper" <grim_reaper@RE MOVEbtopenworld .comwrote in message
            news:-NidnWSQ689l__bY RVnytQ@bt.com.. .
            >You need a WordDoc.Quit after your WordDoc.Close.
            >______________ _______________ ____
            >The Grim Reaper
            >>
            >"Steve" <s.arndt@comcas t.netwrote in message
            >news:eOB0SXmEH HA.2356@TK2MSFT NGP03.phx.gbl.. .
            I've been building an application that will merge fields in a text file
            with
            a word template, save the resulting word file out to the user's hard
            drive,
            and then email the file as an attachment.
            >
            The problem I'm having is that I can't delete the word file I saved at
            the
            end of the process due to the file being locked by the email process.
            It
            appears to take longer than the code takes to complete due to virus
            checking
            software that intercepts the mail before releasing it (at least that's
            what
            I've narrowed it down to).
            >
            I don't want to leave the file around after the code has completed.
            And
            I
            don't think I want to hold up the completion of the code process until
            the
            email gets sent in case the email process takes longer on some machines
            than
            others.
            >
            I'm not sure if there is a better way to handle the attachment in the
            code
            so I don't have to save a file to the user's desktop. Or if I can use
            a
            deattach process that I can trigger from code to delete the file later.
            Or
            something else.
            >
            I've attached a snippet of the code below:
            >
            Thanks
            Steve
            >
            ------------
            >
            WordDoc.SaveAs( sSaveFileName)
            Do While Not WordDoc.Saved
            Application.DoE vents()
            Loop
            WordDoc.Close(W ord.WdSaveOptio ns.wdDoNotSaveC hanges)
            >
            ' Email the Saved Merge Document.
            >
            Dim Fromaddress As New MailAddress("fr omaddress")
            Dim Toaddress As New MailAddress("to address")
            Dim myMail As New MailMessage(Fro maddress, ToAddress)
            myMail.Subject = "test"
            Dim AttachmentFile As Attachment = New Attachment(sSav eFileName)
            myMail.Attachme nts.Add(Attachm entFile)
            myMail.Priority = MailPriority.Hi gh
            Dim client As New SmtpClient
            client.Host = "hostaddres s"
            client.Send(myM ail)
            >
            ' Release the references.
            >
            WordMailMerge = Nothing
            WordDoc = Nothing
            WordApp = Nothing
            >
            ' Delete the temporary files.
            >
            System.IO.File. Delete(sSaveFil eName)
            >
            >
            >
            >
            >>
            >>
            >
            >

            Comment

            • Steve

              #7
              Re: word automation vb.net

              Actually, I discovered it's locked by vshost.exe - which appears to only be
              shut down when the host application is shut down. I guess VB2005 uses
              vshost.exe for performance improvement/debugging.

              Anyway, not sure what to do for now. Note: I'm developing the application
              as I type this.

              Any ideas from anyone?

              Robin:

              How would I create a temp copy of the file?

              Steve

              "RobinS" <RobinS@NoSpam. yah.nonewrote in message
              news:WbOdnXVnj6 oQ4PbYnZ2dnUVZ_ r-dnZ2d@comcast.c om...
              Could you save a separate copy as a temp file and send that
              in the e-mail and then delete it?
              >
              Robin S.
              --------------------------
              "Steve" <s.arndt@comcas t.netwrote in message
              news:%23jnNTInE HHA.4256@TK2MSF TNGP04.phx.gbl. ..
              But this will close the word application which the user running the
              program
              will want to keep open for printing the active document. I am trying to
              blindly send an email (legit) during the process.

              Steve

              "The Grim Reaper" <grim_reaper@RE MOVEbtopenworld .comwrote in message
              news:-NidnWSQ689l__bY RVnytQ@bt.com.. .
              You need a WordDoc.Quit after your WordDoc.Close.
              _______________ _______________ ___
              The Grim Reaper
              >
              "Steve" <s.arndt@comcas t.netwrote in message
              news:eOB0SXmEHH A.2356@TK2MSFTN GP03.phx.gbl...
              I've been building an application that will merge fields in a text
              file
              with
              a word template, save the resulting word file out to the user's hard
              drive,
              and then email the file as an attachment.

              The problem I'm having is that I can't delete the word file I saved
              at
              the
              end of the process due to the file being locked by the email process.
              It
              appears to take longer than the code takes to complete due to virus
              checking
              software that intercepts the mail before releasing it (at least
              that's
              what
              I've narrowed it down to).

              I don't want to leave the file around after the code has completed.
              And
              I
              don't think I want to hold up the completion of the code process
              until
              the
              email gets sent in case the email process takes longer on some
              machines
              than
              others.

              I'm not sure if there is a better way to handle the attachment in the
              code
              so I don't have to save a file to the user's desktop. Or if I can
              use
              a
              deattach process that I can trigger from code to delete the file
              later.
              Or
              something else.

              I've attached a snippet of the code below:

              Thanks
              Steve

              ------------

              WordDoc.SaveAs( sSaveFileName)
              Do While Not WordDoc.Saved
              Application.DoE vents()
              Loop
              WordDoc.Close(W ord.WdSaveOptio ns.wdDoNotSaveC hanges)

              ' Email the Saved Merge Document.

              Dim Fromaddress As New MailAddress("fr omaddress")
              Dim Toaddress As New MailAddress("to address")
              Dim myMail As New MailMessage(Fro maddress, ToAddress)
              myMail.Subject = "test"
              Dim AttachmentFile As Attachment = New Attachment(sSav eFileName)
              myMail.Attachme nts.Add(Attachm entFile)
              myMail.Priority = MailPriority.Hi gh
              Dim client As New SmtpClient
              client.Host = "hostaddres s"
              client.Send(myM ail)

              ' Release the references.

              WordMailMerge = Nothing
              WordDoc = Nothing
              WordApp = Nothing

              ' Delete the temporary files.

              System.IO.File. Delete(sSaveFil eName)




              >
              >
              >
              >

              Comment

              • RobinS

                #8
                Re: word automation vb.net

                The only reason I'd create a second (temp) copy is
                because you said you want to leave Word open for the
                user to print the information in the Word document.
                But if Word is open, the file is still locked.

                The problem is, if you leave it open, and don't
                save it (so it's nowhere), you can't e-mail it.
                And if you save it, you can't delete it because
                you want to leave it open for your user. And
                when he gets around to closing Word, your application
                has already released control of it, and you can't go
                back and delete it.

                I used to create CSV files and then open them
                in Excel using OLE Automation. The user could then
                save the file as an Excel file to wherever he
                wanted to.

                My program let go of the file as soon as it
                showed it to the user in Excel. But I still had
                the pesky CSV files, and couldn't delete them
                if the user still had them open.

                So this is what I did: I created the files in my
                application directory and named them with a specific
                pattern, like Temp_yymmddhhmm ss.csv.

                Then every time they started up the application,
                it would delete any files it found in the application
                folder with the pattern Temp_*.csv.

                Okay, it's tacky, but it worked, and I'm open to
                other suggestions. Since they ran the app all the
                time, it was always "self-cleaning". The other nice
                thing about it was if they didn't save the Excel
                file, they could go open the CSV before they
                started up the app again and get their data.

                So you could save the Word document in the same fashion
                to somewhere (the windows temp folder? the application
                folder?) and e-mail it and leave it open. And when
                your app starts up, go delete any that you find. Be
                sure to catch the exception of the file being locked,
                in case they still have it open. If you put it
                in the windows temp folder, I'd name it something
                really specific, like MyAppName_Temp_ yymmddhhmmss.do c,
                so you don't accidentally delete something else
                when you go back to delete them.

                You can access the name of the Windows temp folder
                using this (VB2005):

                Dim tempFolder as String = New Path.GetTempPat h

                You could get a temporary file name like this, too,
                but then you couldn't delete them yourself (also VB2005):

                Dim tempFileName as String = New Path.GetTempFil eName

                If they don't run your app more than once, I don't
                know that I would do this. The temp files don't get
                deleted automatically. If you *do* do this, and save
                them to the Windows temp folder, and they hardly ever
                run your app, I'd save them with GetTempFileName name.

                By the way, when you double-click on an attachment
                in Outlook and open it, it saves it to the Windows
                temp folder and then opens it. It must have some
                kind of clean-up, or maybe not.

                I hope that helps. Other ideas are welcome!

                Robin S.
                -------------------------------------

                "Steve" <s.arndt@comcas t.netwrote in message
                news:eLmoRLoEHH A.3520@TK2MSFTN GP04.phx.gbl...
                Actually, I discovered it's locked by vshost.exe - which appears to only
                be
                shut down when the host application is shut down. I guess VB2005 uses
                vshost.exe for performance improvement/debugging.
                >
                Anyway, not sure what to do for now. Note: I'm developing the application
                as I type this.
                >
                Any ideas from anyone?
                >
                Robin:
                >
                How would I create a temp copy of the file?
                >
                Steve
                >
                "RobinS" <RobinS@NoSpam. yah.nonewrote in message
                news:WbOdnXVnj6 oQ4PbYnZ2dnUVZ_ r-dnZ2d@comcast.c om...
                >Could you save a separate copy as a temp file and send that
                >in the e-mail and then delete it?
                >>
                >Robin S.
                >--------------------------
                >"Steve" <s.arndt@comcas t.netwrote in message
                >news:%23jnNTIn EHHA.4256@TK2MS FTNGP04.phx.gbl ...
                But this will close the word application which the user running the
                program
                will want to keep open for printing the active document. I am trying
                to
                blindly send an email (legit) during the process.
                >
                Steve
                >
                "The Grim Reaper" <grim_reaper@RE MOVEbtopenworld .comwrote in message
                news:-NidnWSQ689l__bY RVnytQ@bt.com.. .
                >You need a WordDoc.Quit after your WordDoc.Close.
                >______________ _______________ ____
                >The Grim Reaper
                >>
                >"Steve" <s.arndt@comcas t.netwrote in message
                >news:eOB0SXmEH HA.2356@TK2MSFT NGP03.phx.gbl.. .
                I've been building an application that will merge fields in a text
                file
                with
                a word template, save the resulting word file out to the user's hard
                drive,
                and then email the file as an attachment.
                >
                The problem I'm having is that I can't delete the word file I saved
                at
                the
                end of the process due to the file being locked by the email
                process.
                It
                appears to take longer than the code takes to complete due to virus
                checking
                software that intercepts the mail before releasing it (at least
                that's
                what
                I've narrowed it down to).
                >
                I don't want to leave the file around after the code has completed.
                And
                I
                don't think I want to hold up the completion of the code process
                until
                the
                email gets sent in case the email process takes longer on some
                machines
                than
                others.
                >
                I'm not sure if there is a better way to handle the attachment in
                the
                code
                so I don't have to save a file to the user's desktop. Or if I can
                use
                a
                deattach process that I can trigger from code to delete the file
                later.
                Or
                something else.
                >
                I've attached a snippet of the code below:
                >
                Thanks
                Steve
                >
                ------------
                >
                WordDoc.SaveAs( sSaveFileName)
                Do While Not WordDoc.Saved
                Application.DoE vents()
                Loop
                WordDoc.Close(W ord.WdSaveOptio ns.wdDoNotSaveC hanges)
                >
                ' Email the Saved Merge Document.
                >
                Dim Fromaddress As New MailAddress("fr omaddress")
                Dim Toaddress As New MailAddress("to address")
                Dim myMail As New MailMessage(Fro maddress, ToAddress)
                myMail.Subject = "test"
                Dim AttachmentFile As Attachment = New Attachment(sSav eFileName)
                myMail.Attachme nts.Add(Attachm entFile)
                myMail.Priority = MailPriority.Hi gh
                Dim client As New SmtpClient
                client.Host = "hostaddres s"
                client.Send(myM ail)
                >
                ' Release the references.
                >
                WordMailMerge = Nothing
                WordDoc = Nothing
                WordApp = Nothing
                >
                ' Delete the temporary files.
                >
                System.IO.File. Delete(sSaveFil eName)
                >
                >
                >
                >
                >>
                >>
                >
                >
                >>
                >>
                >
                >

                Comment

                • Robinson

                  #9
                  Re: word automation vb.net

                  So this is what I did: I created the files in my
                  application directory and named them with a specific
                  pattern, like Temp_yymmddhhmm ss.csv.
                  >
                  Then every time they started up the application,
                  it would delete any files it found in the application
                  folder with the pattern Temp_*.csv.
                  I do this with temporary files. Typically I generate a hundred or so during
                  an average running session, which are all in a user data directory. This
                  directory is cleaned during program startup.



                  Comment

                  • Chris Dunaway

                    #10
                    Re: word automation vb.net

                    Steve wrote:
                    ' Release the references.
                    >
                    WordMailMerge = Nothing
                    WordDoc = Nothing
                    WordApp = Nothing
                    Setting the objects to Nothing does not release them. For COM objects
                    you need to call Marshal.Release ComObject.

                    Comment

                    • RobinS

                      #11
                      Re: word automation vb.net

                      Thanks -- that makes me feel better. I just couldn't think
                      of another way. I was afraid I was going to get a lot of
                      negative feedback for the method I chose!

                      Robin S.
                      -------------------------------
                      "Robinson" <bbb@bbb.comwro te in message
                      news:lqWdnaW6x-GqZPbYnZ2dnUVZ8 tidnZ2d@giganew s.com...
                      >
                      >So this is what I did: I created the files in my
                      >application directory and named them with a specific
                      >pattern, like Temp_yymmddhhmm ss.csv.
                      >>
                      >Then every time they started up the application,
                      >it would delete any files it found in the application
                      >folder with the pattern Temp_*.csv.
                      >
                      I do this with temporary files. Typically I generate a hundred or so
                      during an average running session, which are all in a user data directory.
                      This directory is cleaned during program startup.
                      >
                      >
                      >

                      Comment

                      • Steve

                        #12
                        Re: word automation vb.net

                        I figured out a solution to my problem. After client.send, I issue a
                        mymail.dispose. It releases the hold on the file which allows me to delete
                        it.

                        Steve

                        -----

                        Dim Fromaddress As New MailAddress("fr omaddress")
                        Dim Toaddress As New MailAddress("to address")
                        Dim myMail As New MailMessage(Fro maddress, ToAddress)
                        myMail.Subject = "test"
                        Dim AttachmentFile As Attachment = New Attachment(sSav eFileName)
                        myMail.Attachme nts.Add(Attachm entFile)
                        myMail.Priority = MailPriority.Hi gh
                        Dim client As New SmtpClient
                        client.Host = "hostaddres s"
                        client.Send(myM ail
                        myMail.Dispose( )




                        "RobinS" <RobinS@NoSpam. yah.nonewrote in message
                        news:Nd6dneRc9M 2bGfHYnZ2dnUVZ_ vadnZ2d@comcast .com...
                        Thanks -- that makes me feel better. I just couldn't think
                        of another way. I was afraid I was going to get a lot of
                        negative feedback for the method I chose!
                        >
                        Robin S.
                        -------------------------------
                        "Robinson" <bbb@bbb.comwro te in message
                        news:lqWdnaW6x-GqZPbYnZ2dnUVZ8 tidnZ2d@giganew s.com...
                        So this is what I did: I created the files in my
                        application directory and named them with a specific
                        pattern, like Temp_yymmddhhmm ss.csv.
                        >
                        Then every time they started up the application,
                        it would delete any files it found in the application
                        folder with the pattern Temp_*.csv.
                        I do this with temporary files. Typically I generate a hundred or so
                        during an average running session, which are all in a user data
                        directory.
                        This directory is cleaned during program startup.

                        >
                        >

                        Comment

                        • RobinS

                          #13
                          Re: word automation vb.net

                          Woohoo! Thanks for letting us know.
                          Congrats.
                          Robin S.
                          --------------------------------------
                          "Steve" <s.arndt@comcas t.netwrote in message
                          news:ua28By$EHH A.5000@TK2MSFTN GP03.phx.gbl...
                          >I figured out a solution to my problem. After client.send, I issue a
                          mymail.dispose. It releases the hold on the file which allows me to
                          delete
                          it.
                          >
                          Steve
                          >
                          -----
                          >
                          Dim Fromaddress As New MailAddress("fr omaddress")
                          Dim Toaddress As New MailAddress("to address")
                          Dim myMail As New MailMessage(Fro maddress, ToAddress)
                          myMail.Subject = "test"
                          Dim AttachmentFile As Attachment = New Attachment(sSav eFileName)
                          myMail.Attachme nts.Add(Attachm entFile)
                          myMail.Priority = MailPriority.Hi gh
                          Dim client As New SmtpClient
                          client.Host = "hostaddres s"
                          client.Send(myM ail
                          myMail.Dispose( )
                          >
                          >
                          >
                          >
                          "RobinS" <RobinS@NoSpam. yah.nonewrote in message
                          news:Nd6dneRc9M 2bGfHYnZ2dnUVZ_ vadnZ2d@comcast .com...
                          >Thanks -- that makes me feel better. I just couldn't think
                          >of another way. I was afraid I was going to get a lot of
                          >negative feedback for the method I chose!
                          >>
                          >Robin S.
                          >-------------------------------
                          >"Robinson" <bbb@bbb.comwro te in message
                          >news:lqWdnaW 6x-GqZPbYnZ2dnUVZ8 tidnZ2d@giganew s.com...
                          >
                          >So this is what I did: I created the files in my
                          >application directory and named them with a specific
                          >pattern, like Temp_yymmddhhmm ss.csv.
                          >>
                          >Then every time they started up the application,
                          >it would delete any files it found in the application
                          >folder with the pattern Temp_*.csv.
                          >
                          I do this with temporary files. Typically I generate a hundred or so
                          during an average running session, which are all in a user data
                          directory.
                          This directory is cleaned during program startup.
                          >
                          >
                          >
                          >>
                          >>
                          >
                          >

                          Comment

                          Working...