Email report using GroupWise

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32645

    #16
    Working from the code you posted in post #7...
    Code:
    'Line added
    Private Const conFile As String = _
                      "C:\Documents and Settings\reo\My Documents\" & _
                      "ContractReports\ReportsOConnor.rtf"
    
    Function ROconnerMail()
    'Line changed
      If Exist(conFile) Then Call RunROconnerEMail(strFile:=conFile)
    End Function
    
    'Line changed
    Sub RunROconnerEMail(ByRef strFile As String)
    
      On Error GoTo Err_Handler
      Dim strTemp As String
      Dim varAttach(2) As Variant
      Dim strRecTo(1, 0) As String
      Dim strRecCc(1, 0) As String
      Dim lngCount As Long
      Dim varProxies As Variant
      Dim cGW As GW
    
    'Line changed
      varAttach(0) = strFile
    
      strRecTo(0, 0) = "reo@propeople.org"
      strRecTo(1, 0) = "reo@propeople.org"
      strRecCc(0, 0) = "tpg@propeople.org"
    
      Set cGW = New GW
      With cGW
        .Login
        .BodyText = "Attached please find a word document that lists: " & _
                    "contract reports that are over due and contract reports " & _
                    "that are due within one to three weeks.  " & vbCrLf & vbCrLf & _
                    "Please ensure that the reports are completed and sent " & _
                    "to the contract officer on time.  A copy of the dated " & _
                    "cover letter transmitting the report and the report " & _
                    "itself should be sent to the Accounting Specialist in " & _
                    "the Finance Office.  The Accounting Specialist will " & _
                    "update the Contracts database with the date the report " & _
                    "was submitted and file the report in the contract file " & _
                    "for the compliance audits." & vbCrLf & vbCrLf & _
                    "If no document is attached to this automated e-mail " & _
                    "then you have no past due reports and no reports due " & _
                    "within the next three weeks." & vbCrLf & vbCrLf & _
                    "For questions please contact the Accounting Specialist " & _
                    "at 874-1140 ext 356. Thank you."
        .Subject = "Contract Reports"
        .RecTo = strRecTo
        .RecCc = strRecCc
        .FileAttachments = varAttach
        .FromText = "Finance Department"
        .Priority = "High"
        strTemp = .CreateMessage
        .ResolveRecipients strTemp
        If IsArray(.NonResolved) Then MsgBox "Some unresolved recipients."
        .SendMessage strTemp
        .DeleteMessage strTemp, True
      End With
    
    Exit_Here:
      Set cGW = Nothing
    Exit Sub

    Comment

    • pixie
      New Member
      • Sep 2006
      • 41

      #17
      OK. I have it in the General Module as its own module. What next? Boy, do I really appreciate all your attention and help.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32645

        #18
        I hope you refreshed after posting and saw the other posts ;)

        Comment

        • pixie
          New Member
          • Sep 2006
          • 41

          #19
          Good morning. I was in a meeting yesterday afternoon (a rare thing for me) so didn't see the rest of your reply till late. I just added it but for some reason I can't run it. Should the first two line changes go in a new module?

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32645

            #20
            I'm a bit confused by the last bit (your question).
            Where do you have the code currently (Module names and Types pls)? What is the name of the form you're working in?
            There is some flexibility here as to where things can go, so if I know what you have where, I can better explain where it would be easiest for you to put the changes.

            Comment

            • pixie
              New Member
              • Sep 2006
              • 41

              #21
              I have the first bit of code in a Module called DontMailIfNoAtt achment. I added the second code you sent to the Module called basOBowman. (I am testing this out on Bowman not OConnor as Bowman's mail goes to me till she is replaced.) So here is what it looks like but when I go to run, I cant find it to run it.

              Code:
              Option Compare Database
              
              Option Explicit
              'Line added
              Private Const conFile As String = _
                                "G:\Accounting\Development\ReportsBowman.rtf"
                                
              Function OBowmanMail()
              'Line changed
                If Exist(conFile) Then Call RunOBowmanEMail(strFile:=conFile)
              End Function
              
              Sub RunOBowmanEMail(ByRef strFile As String)
              
              On Error GoTo Err_Handler
              Dim strTemp As String
              Dim varAttach(2) As Variant
              Dim strRecTo(1, 0) As String
              Dim strRecCc(1, 0) As String
              Dim lngCount As Long
              Dim varProxies As Variant
              Dim intRes As Integer
              Dim strMsg As String
              Dim cancel As Boolean
              
              Dim cGW As GW
              'Line chance
               varAttach(0) = strFile
              
              
              strRecTo(0, 0) = "bjo@propeople.org"
              strRecTo(1, 0) = "bjo@propeople.org"
              
              strRecCc(0, 0) = "bjo@propeople.org"

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32645

                #22
                Will have to look at this tomorrow. Sorry - I'm out tonight.
                Expect rational response then ;)

                Comment

                • pixie
                  New Member
                  • Sep 2006
                  • 41

                  #23
                  Enjoy the night and thanks again for all the help thus far. Looking forward to hearing your response.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32645

                    #24
                    I've looked at this a little more closely and I think I may have an answer for you.
                    Only think, because your answer seems to be almost contradictory. You say the code is in two separate modules yet you post them both in the same code window.
                    If they are simply in three separate modules (as implied) then putting the word Public before each procedure (Sub or Function) definition should make them visible to other modules in the same Project.
                    Let us know if this fixes your problem. If not, try to explain where your code is located a little more clearly. Hopefully it will be fine with this though. Good luck.

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32645

                      #25
                      Originally posted by pixie
                      Enjoy the night and thanks again for all the help thus far. Looking forward to hearing your response.
                      BTW I had a fine night thank you.
                      I was a bouncer for my niece's 18th birthday party. It was quite funny watching the behaviour of all the young things. There was no worry though (18th birthdays are notorious for trouble usually) as two of my nephews also do karate and were there inside in case of any trouble.

                      Comment

                      • pixie
                        New Member
                        • Sep 2006
                        • 41

                        #26
                        Thanks for the reponse. I have to work on three other projects today but will try to find some free time today to get back to you as I so want to have this one wrapped up. Glad you had a nice evening the other night.

                        Comment

                        • NeoPa
                          Recognized Expert Moderator MVP
                          • Oct 2006
                          • 32645

                          #27
                          No hurry.
                          When you can, let us know if the Public fix worked for you.

                          Comment

                          • pixie
                            New Member
                            • Sep 2006
                            • 41

                            #28
                            Hi, I'm taking a break from my other projects and just entered the Public before all three modules. I can't find the module in my list to run it so I must be doing something dreadfully wrong. Thanks in advance. May I ask if you are in the States?

                            Here they are:

                            The one you sent me:

                            Code:
                            Option Compare Database
                            
                            
                            Option Explicit
                            
                            'Exist returns true if strFile exists.
                            '22/05/2003 Rewritten with better code.
                            '20/05/2005 Added finding of R/O, System & Hidden files
                            Public Function Exist(strFile As String, _
                                                  Optional intAttrib As Integer = &H7) As Boolean
                                Exist = (Dir(PathName:=strFile, Attributes:=intAttrib) <> "")
                            End Function
                            
                            Public Const ConFile As String = _
                                "G:\Accounting\Development\reportsBowman.rtf"
                            Then this one:

                            Code:
                            Option Compare Database
                            Public Const ConFile As String = "G:\Accounting\Development\reportsBowman.rtf"
                            
                            
                            Public Function BowmanMail()
                            If Exist(ConFile) Then Call RunOBowmanEMail(strFile:=ConFile)
                            End Function
                            Then the last one:

                            Code:
                            Public Sub RunOBowmanEMail(ByRef strFile As String)
                            
                            On Error GoTo Err_Handler
                            Dim strTemp As String
                            Dim varAttach(2) As Variant
                            Dim strRecTo(1, 0) As String
                            Dim strRecCc(1, 0) As String
                            Dim lngCount As Long
                            Dim varProxies As Variant
                            Dim intRes As Integer
                            Dim strMsg As String
                            Dim cancel As Boolean
                            
                            Dim cGW As GW
                            
                            
                            varAttach(0) = strFile
                            
                            strRecTo(0, 0) = "bjo@propeople.org"
                            strRecTo(1, 0) = "bjo@propeople.org"
                            
                            strRecCc(0, 0) = "bjo@propeople.org"
                            
                              
                            Set cGW = New GW
                            With cGW
                              .Login
                              .BodyText = "Attached please find ECT."
                              .Subject = "Contract Reports"
                              .RecTo = strRecTo
                              .RecCc = strRecCc
                              .FileAttachments = varAttach
                              .FromText = "Finance Department"
                              .Priority = "High"
                              strTemp = .CreateMessage
                              .ResolveRecipients strTemp
                              If IsArray(.NonResolved) Then MsgBox "Some unresolved recipients."
                              .SendMessage strTemp
                              .DeleteMessage strTemp, True
                            End With

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32645

                              #29
                              That is the idea with the Public keyword.
                              Does it fix the problem for you?
                              In answer to your question, No I live in South London (My profile will give all my publicly accessible details).

                              Comment

                              • pixie
                                New Member
                                • Sep 2006
                                • 41

                                #30
                                I'm not sure if it does solve my problem. When I am in VBA and go to Run on the Menu bar | Run Sub/UserForm, it shows all the modules except those three that I posted here. I must be doing something dreadfully wrong. Oh, and thanks for pointing out your profile.

                                Comment

                                Working...