How to Attach the File in a Email using VB & Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ttamilvanan81
    New Member
    • Mar 2007
    • 35

    #16
    Originally posted by iburyak
    You should have edit rights on your C: drive.

    Can you create a text file on your C drive with no problem?

    If not this is a problem VB needs some rights on your local drive to make it work.

    Also it is possible that you are using not authentic VB version.

    Thank you.
    I am not have the VB in my System. I have only the Ms-Access.
    In my system i don't install the Visual Basic. I can only using the Ms-Access.
    If i will go to install any ActiveX control for Ms-Access. Where i go to install the ActiveX Control, and how to Register the Controls?


    Thanks
    Tamilvanan

    Comment

    • ttamilvanan81
      New Member
      • Mar 2007
      • 35

      #17
      Originally posted by iburyak
      You should have edit rights on your C: drive.

      Can you create a text file on your C drive with no problem?

      If not this is a problem VB needs some rights on your local drive to make it work.

      Also it is possible that you are using not authentic VB version.

      Thank you.
      Yes. I have the rights to create the text file without any problem in c:
      But, in my system don't have the VB. So that the problem araise?
      If VB doesn't installed the system, where i go to install the ActiveX controls?
      or
      Must install the Vb in my system?

      Please, reply me.

      Thanks
      Tamilvanan

      Comment

      • vijaydiwakar
        Contributor
        • Feb 2007
        • 579

        #18
        ya u may install vb
        just proceed
        Good Luck

        Comment

        • ttamilvanan81
          New Member
          • Mar 2007
          • 35

          #19
          Thanks for all your replies.
          Now i have access the Common Dialog Control.
          But another one problem raised. When i go to Browse and select the file. The file content was stored in the textbox.
          But i need to store the file path only. I am using the following code
          Code:
          Private Sub Command2_Click()
          
          Dim sFileName As String, NextLine As String
          Dim FH As Long
              
          With CommonDialog1
              .CancelError = True
              .Filter = "All Files(*.*)|*.*|Text Files(*.txt)|*.txt"
              .FilterIndex = 2
              .InitDir = "I use this property when I have default directory standard or in many cases I save last used path"
              .ShowOpen
              
              sFileName = .FileName
          End With
               
          FH = FreeFile()
              
          Open sFileName For Input Access Read Shared As #FH
              
          Do Until EOF(FH)
              Line Input #FH, NextLine
              Text3.Value = Text3.Value & NextLine
          Loop
          
          Close #FH
          
           End Sub
          Please post me the Details. Am waiting for any one reply.


          Thanks
          Tamilvanan

          Comment

          • iburyak
            Recognized Expert Top Contributor
            • Nov 2006
            • 1016

            #20
            Just change this:

            [PHP]FH = FreeFile()

            Open sFileName For Input Access Read Shared As #FH

            Do Until EOF(FH)
            Line Input #FH, NextLine
            Text3.Value = Text3.Value & NextLine
            Loop

            Close #FH

            End Sub[/PHP]

            to this:

            [PHP]Text3.text = sFileName [/PHP]

            Comment

            • MMcCarthy
              Recognized Expert MVP
              • Aug 2006
              • 14387

              #21
              This thread is being moved to the Access forum.

              ADMIN

              Comment

              • MMcCarthy
                Recognized Expert MVP
                • Aug 2006
                • 14387

                #22
                Originally posted by ttamilvanan81
                Thanks for all your replies.
                Now i have access the Common Dialog Control.
                But another one problem raised. When i go to Browse and select the file. The file content was stored in the textbox.
                But i need to store the file path only. I am using the following code
                Code:
                Private Sub Command2_Click()
                
                Dim sFileName As String, NextLine As String
                Dim FH As Long
                    
                With CommonDialog1
                    .CancelError = True
                    .Filter = "All Files(*.*)|*.*|Text Files(*.txt)|*.txt"
                    .FilterIndex = 2
                    .InitDir = "I use this property when I have default directory standard or in many cases I save last used path"
                    .ShowOpen
                    
                    sFileName = .FileName
                End With
                     
                FH = FreeFile()
                    
                Open sFileName For Input Access Read Shared As #FH
                    
                Do Until EOF(FH)
                    Line Input #FH, NextLine
                    Text3.Value = Text3.Value & NextLine
                Loop
                
                Close #FH
                
                 End Sub
                Please post me the Details. Am waiting for any one reply.


                Thanks
                Tamilvanan
                I'm not sure what you are trying to do that this code is not currently doing. Can you explain further?

                Mary

                Comment

                • ttamilvanan81
                  New Member
                  • Mar 2007
                  • 35

                  #23
                  Originally posted by iburyak
                  Just change this:

                  [PHP]FH = FreeFile()

                  Open sFileName For Input Access Read Shared As #FH

                  Do Until EOF(FH)
                  Line Input #FH, NextLine
                  Text3.Value = Text3.Value & NextLine
                  Loop

                  Close #FH

                  End Sub[/PHP]

                  to this:

                  [PHP]Text3.text = sFileName [/PHP]


                  Thank you iburyak.
                  Am change the code as you said. But still i have the problem.

                  If i have change the code
                  Text1.Text = Text1.Text & NextLine & vbCrLf
                  as
                  Text3.text = sFileName
                  following error message will be shown.

                  you can't reference a property or method for a control unless the control has the focus
                  So i had stuck.

                  Please post me the details, i am waiting for reply.

                  Thanks
                  Tamilvanan

                  Comment

                  • ttamilvanan81
                    New Member
                    • Mar 2007
                    • 35

                    #24
                    Originally posted by mmccarthy
                    I'm not sure what you are trying to do that this code is not currently doing. Can you explain further?

                    Mary

                    Hai. i am trying to send and receive email using Ms-Access. I am complete the Send Email. But still the attachment pending.
                    I need the browse button, to browse and select the file, the selected file path was stored in a text box.

                    Thats why am using the above coding. But if i go to browse and select the file using those code, the selected file content was stored in the text box.

                    I need only the path will be stored in that text box.

                    Can you know how this will be solve? Please let me know.

                    Thanks
                    Tamilvanan

                    Comment

                    • iburyak
                      Recognized Expert Top Contributor
                      • Nov 2006
                      • 1016

                      #25
                      Originally posted by mmccarthy
                      I'm not sure what you are trying to do that this code is not currently doing. Can you explain further?

                      Mary
                      Mary,

                      This is his problem and I am not sure how to help him in Access.


                      I am Try to drag and drop that control But i cant.
                      Actually in Access forn Design view, Normal Toolbox does not contain that controls. So am go to click the more controls button. Then am select the Microsoft Common Dialog Control, Version 6.0 . Other Two Controls are not displayed.

                      The Error message displays, while select the control. The Erro Message is.

                      you don't have the license required to use this ActiveX control.
                      You tried to open a form containing an OLE object or an ActiveX control or you tried to create an ActiveX control. To obtain the appropriate license, contact the company that provides the licensed OLE object or ActiveX control.


                      So how to Rectify this error. Why this Error was Occured, while drag and drop the control.

                      Please post me the detail.

                      Thanks,

                      Tamilvanan

                      Comment

                      • iburyak
                        Recognized Expert Top Contributor
                        • Nov 2006
                        • 1016

                        #26
                        Originally posted by ttamilvanan81
                        Hai. i am trying to send and receive email using Ms-Access. I am complete the Send Email. But still the attachment pending.
                        I need the browse button, to browse and select the file, the selected file path was stored in a text box.

                        Thats why am using the above coding. But if i go to browse and select the file using those code, the selected file content was stored in the text box.

                        I need only the path will be stored in that text box.

                        Can you know how this will be solve? Please let me know.

                        Thanks
                        Tamilvanan
                        ttamilvanan81,
                        you didn't reply to me if you are able to create any text file on your C drive.
                        It looks like you don't have rights that required running VBA and there is no way forum can help you with that.

                        Comment

                        • MMcCarthy
                          Recognized Expert MVP
                          • Aug 2006
                          • 14387

                          #27
                          Originally posted by iburyak
                          Mary,

                          This is his problem and I am not sure how to help him in Access.
                          Ok so you've been trying to use the activeX control and you are getting the no licence warning. Try this ...

                          Go to the VBA Editor
                          Go to Tools - Referances - click Browse
                          Locate the activex file (comdlg32.ocx)
                          The add referance box will register your activeX into the list box on the left pane.

                          This should register the ActiveX control and stop this warning from appearing.

                          Mary

                          Comment

                          • MMcCarthy
                            Recognized Expert MVP
                            • Aug 2006
                            • 14387

                            #28
                            This code is opening the file and storing it in the textbox.
                            Code:
                            FH = FreeFile()
                                
                            Open sFileName For Input Access Read Shared As #FH
                                
                            Do Until EOF(FH)
                                Line Input #FH, NextLine
                                Text3.Value = Text3.Value & NextLine
                            Loop
                            
                            Close #FH
                            If all you want is the filepath then try ...

                            Code:
                                 Text3.Value = sFileName
                            instead of that code.

                            Mary

                            Comment

                            • ttamilvanan81
                              New Member
                              • Mar 2007
                              • 35

                              #29
                              Originally posted by mmccarthy
                              Ok so you've been trying to use the activeX control and you are getting the no licence warning. Try this ...

                              Go to the VBA Editor
                              Go to Tools - Referances - click Browse
                              Locate the activex file (comdlg32.ocx)
                              The add referance box will register your activeX into the list box on the left pane.

                              This should register the ActiveX control and stop this warning from appearing.

                              Mary
                              Hai. Thanks for your reply. Am already do that, to Register the COMDLG32.OCX. But i didn't do the Register.
                              Am tryed what u said as,

                              The add referance box will register your activeX into the list box on the left pane.

                              But the Available Reference box list out the control, named

                              Microsoft Common Dialog Control6.0 (sp3). Then the Same Error Message occured. Then what to do.

                              Did u meant the Add Reference Box (list box) or Available References list Box ?

                              If u meant is add Reference Box. Tell me how to pick the add reference box?

                              Am waiting for your reply.

                              Thanks
                              Tamilvanan

                              Comment

                              • ttamilvanan81
                                New Member
                                • Mar 2007
                                • 35

                                #30
                                Originally posted by iburyak
                                ttamilvanan81,
                                you didn't reply to me if you are able to create any text file on your C drive.
                                It looks like you don't have rights that required running VBA and there is no way forum can help you with that.
                                Hai. I have the rights to create the text fiel in my C Drive.
                                That's no problem for creating the file.
                                am goes to create a text file, it's creted successfully.

                                Can u post the any other method.

                                Thanks
                                Tamilvanan

                                Comment

                                Working...