send email without using a macro

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jeffrey Tan
    New Member
    • Jan 2011
    • 86

    #46
    @ADezii

    yeah i changed them all to acFormatPDF, but weird how im still getting an error..

    i was thinking it could be a missing reference, but i checked the references my collegue has and it's the same.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #47
      If that doesn't enable you to find it by yourself, post the current code and indicate which line triggers the error.

      Comment

      • Jeffrey Tan
        New Member
        • Jan 2011
        • 86

        #48
        Code:
        If FileExists(strDestination & title & [Forms]![User Problem Log]![trouble_no] & "*") Then
                Kill strDestination & title & [Forms]![User Problem Log]![trouble_no] & "*"
                DoCmd.OutputTo acOutputReport, "Email-" & Mid(strReportName, 1, 6), acFormatPDF, strDestination & _
                        "\" & strReportName & ".pdf", False
             Else
                 DoCmd.OutputTo acOutputReport, "Email-" & Mid(strReportName, 1, 6), acFormatPDF, strDestination & _
                        "\" & strReportName & ".pdf", False
             End If
        line #6-7... when i click on the button to email, it just breaks on that line...

        it's weird since i have adobe acrobat installed, pdf writer and all that.

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #49
          Did you make sure you have the folder "C:\Documen ts and Settings\jtan\D esktop\Files\" on your laptop?

          Also, in your code, you have strDestination & "\". Which means you get "C:\Documen ts and Settings\jtan\D esktop\Files\\"

          Comment

          • Jeffrey Tan
            New Member
            • Jan 2011
            • 86

            #50
            @Rabbit: there is code above that creates the directory if it does not exist. sorry forgot to add that in post

            Code:
            If Not FileExists(strDestination) Then
                   MkDir (strDestination)
                End If
            originally, the strDestination was C:\Windows\Temp \.

            I have a feeling it's got something to do with Adobe PDF on my machine.

            during the day, i downloaded this template from microsoft called "call tracker" and there was this button that had email formats


            I clicked on the button, but i do not see Adobe PDF on it.. so that's the thing I'm confused about.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32633

              #51
              Jeffrey, did you miss Rabbit's point. The problem is that you have doubled up on the "\" characters. He's correct. That is your problem.

              Comment

              • Jeffrey Tan
                New Member
                • Jan 2011
                • 86

                #52
                @NeoPa:

                oh. I'll try that when i get to work today. Maybe that is the problem. Thanks!

                Hopefully it is so this can be closed once and for all :P

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32633

                  #53
                  There's no question about it Jeffrey. Even if there are any other problems, that is certainly going to cause your issue all by itself. Your code clearly adds an extra "\" in a few places, which will cause file references to fail.

                  Comment

                  • Jeffrey Tan
                    New Member
                    • Jan 2011
                    • 86

                    #54
                    @NeoPa:

                    It just puzzles me because the code I sent to my collegue is the exact one i have and his worked. but i'll be sure to double check every line of code when i go to the office.

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32633

                      #55
                      I understand Jeffrey.

                      We can only work with what's in front of us though. I doubt the code you sent to your colleague is exactly as you posted for us (otherwise it wouldn't work), but that isn't a puzzle we need to worry about just now. If that doesn't resolve itself in the wash then we can look at that too, but we'd need a new question and the code your colleague is actually using (rather than what you think you sent to him at some point - however close a match that may or may not turn out to be).

                      For now though, I'm confident the code you posted has that problem in it (even if there may be others too).

                      Comment

                      • Jeffrey Tan
                        New Member
                        • Jan 2011
                        • 86

                        #56
                        @NeoPa:

                        yep. what i will do is copy the exact code from my colleague's database, put it into mine and test it.

                        in terms of programs and all, what are usually the requirements to get AcFormatPDF to work?

                        Microsoft Access 2007
                        Adobe Acrobat

                        do you know of anything else?

                        trying to open up some possibilities and narrow them down when i troubleshoot this. :)

                        Comment

                        • NeoPa
                          Recognized Expert Moderator MVP
                          • Oct 2006
                          • 32633

                          #57
                          Originally posted by Jeffrey
                          Jeffrey:
                          yep. what i will do is copy the exact code from my colleague's database, put it into mine and test it.
                          I hope you're referring to what you will do after we finish here. That is not something for this thread. Nor is the question about how to work with PDFs.

                          For now, you need to fix the code you posted earlier, exactly as suggested by Rabbit, and report on your success.

                          Anything further can find its way into a new thread if required.

                          Comment

                          • Jeffrey Tan
                            New Member
                            • Jan 2011
                            • 86

                            #58
                            understood :)

                            thanks again for all this help.

                            Comment

                            • ADezii
                              Recognized Expert Expert
                              • Apr 2006
                              • 8834

                              #59
                              @NeoPa & Rabbit:
                              Ironically, the addition of an extra '\' in the OutputFile Argument of the OutputTo() Method, between the lowest level Folder and start of the Filename, will work. The following Code will work with no problems (notice addition of extra '\'):
                              Code:
                              DoCmd.OutputTo acOutputTable, "tblEmployees", acFormatRTF, "C:\Windows\\Employees.rtf", False

                              Comment

                              • Jeffrey Tan
                                New Member
                                • Jan 2011
                                • 86

                                #60
                                ok im at work now and i fixed the additional "\" but still the same problem.

                                here's the code:

                                Code:
                                Sub sendEmail()
                                
                                'Provides the Send Mail automation. Send an E-Mail and Attachment from Access via Outlook
                                Dim oLook As Object
                                Dim oMail As Object
                                Dim olns As Outlook.NameSpace
                                Dim strRecipient As String
                                Dim strBody As String
                                Dim strSubject As String
                                Dim strReportName As String
                                Dim strSource As String
                                Dim strDestination As String
                                Dim title As String
                                  
                                Set oLook = CreateObject("Outlook.Application")
                                Set olns = oLook.GetNamespace("MAPI")
                                Set oMail = oLook.CreateItem(0)
                                  
                                '************************** Define your own Values here **************************
                                
                                strRecipient = ""
                                strBody = ""
                                strSubject = "Problem Tracking Ticket #: " & [Forms]![User Problem Log]![trouble_no]
                                strReportName = Mid("Email-Single", 7) & " Problem Tracking Ticket # " & [Forms]![User Problem Log]![trouble_no]
                                
                                '*********************************************************************************
                                  
                                strSource = CurrentProject.Path & "\"
                                strDestination = "C:\Windows\Temp\" 'give destination
                                title = "Single Problem Tracking Ticket # "
                                
                                    If Not FileExists(strDestination) Then
                                        MkDir (strDestination)
                                    End If
                                    If FileExists(strDestination & title & [Forms]![User Problem Log]![trouble_no] & ".pdf") Then
                                        Kill strDestination & title & [Forms]![User Problem Log]![trouble_no] & ".pdf"
                                        DoCmd.OutputTo acOutputReport, "Email-" & Mid(strReportName, 1, 6), acFormatPDF, strDestination & strReportName & ".pdf", False
                                    Else
                                        DoCmd.OutputTo acOutputReport, "Email-" & Mid(strReportName, 1, 6), acFormatPDF, strDestination & strReportName & ".pdf", False
                                    End If
                                    With oMail
                                      .To = strRecipient
                                      .Body = strBody
                                      .Subject = strSubject
                                      .Attachments.Add strDestination & strReportName & ".pdf", False
                                      .Display
                                    End With
                                End Sub

                                Comment

                                Working...