AccessXP/Groupwise fix

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

    AccessXP/Groupwise fix

    Hi All,
    Below is a function I want to use in AccessXP, it works as is but as
    the comment says I need to manually open Tools - References and check
    off 'Groupware Type Library' and I'm hoping someone here can show me
    some sample code so I do not have to do that manually. If I run this
    without that library checked off I get this error message
    'Compile Error - User Defined Type Not Defined'
    thanks
    bobh.

    Public Function SendGWMail(Disp layMsg As Boolean, _
    strTo As String, strCC As String, strBCC As String, _
    strSubject As String, strBody As String, strAttachPathFi le As String)
    As Boolean

    ' In order for this function to work you must check Groupware Type
    Library under Tools - References
    ' This will log you in to Groupwise if you are not logged in already
    except if you have your
    ' Groupwise account password protected then you must log-in to
    Groupwise first.
    Const NGW$ = "NGW"
    Dim GWCom As Object
    Dim RetStr As String, MessageId As String

    SendGWMail = False

    ' Create the Groupwise session
    Dim gwappl As GroupwareTypeLi brary.Applicati on2
    Dim gwacc As GroupwareTypeLi brary.Account2
    Dim gwnewmessage As GroupwareTypeLi brary.Message

    Set gwappl = CreateObject("N ovellGroupWareS ession")
    Set gwacc = gwappl.Login
    Set gwnewmessage = gwacc.WorkFolde r.Messages.Add( "GW.Message.mai l",
    egwDraft)

    ' Create the message
    With gwnewmessage
    With .Recipients
    ' Add the To recipient(s) to the message
    If (strTo <"") Then
    '.Add strTo
    .Add strTo, NGW, egwTo
    End If
    ' Add the CC recipient(s) to the message
    If (strCC <"") Then
    .Add strCC, NGW, egwCC
    End If
    ' Add the BCC recipient(s) to the message
    If (strBCC <"") Then
    .Add strBCC, NGW, egwBC
    End If
    End With

    ' Set the Subject, Body, and Importance of the message
    .Subject = strSubject
    .BodyText = strBody
    .Priority = egwHigh

    ' Add attachments to the message.
    If (strAttachPathF ile <"") Then
    .Attachments.Ad d strAttachPathFi le, egwFile
    End If

    ' Should we display the message before sending?
    If DisplayMsg Then
    ' Display message to user
    MessageId = .MessageId
    Set GWCom = CreateObject("G roupwiseCommand er")
    GWCom.Execute "ItemOpen (""" & MessageId & """)", RetStr
    GWCom.Execute "ItemSetTex t (""X00"";To! ; """ & strTo & """; 0)",
    RetStr
    Else
    .Send
    End If

    End With

    SendGWMail = True
    Set gwnewmessage = Nothing

    End Function

  • bobh

    #2
    Re: AccessXP/Groupwise fix

    Ooops! I should also mention that is in an application that I'll be
    distributing to several other users and I don't want to have to go to
    each users pc and check off the reference.

    and the line of code it highlights with the error is the first set
    command
    Set gwappl = CreateObject("N ovellGroupWareS ession")
    I'm assuming whatever I need to do for the first Set command I'll also
    need to do for the second Set command and maybe the third.
    bobh.

    On May 15, 1:24 pm, bobh <vulca...@isp.c omwrote:
    Hi All,
    Below is a function I want to use in AccessXP, it works as is but as
    the comment says I need to manually open Tools - References and check
    off 'Groupware Type Library' and I'm hoping someone here can show me
    some sample code so I do not have to do that manually. If I run this
    without that library checked off I get this error message
    'Compile Error - User Defined Type Not Defined'
    thanks
    bobh.
    >
    Public Function SendGWMail(Disp layMsg As Boolean, _
    strTo As String, strCC As String, strBCC As String, _
    strSubject As String, strBody As String, strAttachPathFi le As String)
    As Boolean
    >
    ' In order for this function to work you must check Groupware Type
    Library under Tools - References
    ' This will log you in to Groupwise if you are not logged in already
    except if you have your
    ' Groupwise account password protected then you must log-in to
    Groupwise first.
    Const NGW$ = "NGW"
    Dim GWCom As Object
    Dim RetStr As String, MessageId As String
    >
    SendGWMail = False
    >
    ' Create the Groupwise session
    Dim gwappl As GroupwareTypeLi brary.Applicati on2
    Dim gwacc As GroupwareTypeLi brary.Account2
    Dim gwnewmessage As GroupwareTypeLi brary.Message
    >
    Set gwappl = CreateObject("N ovellGroupWareS ession")
    Set gwacc = gwappl.Login
    Set gwnewmessage = gwacc.WorkFolde r.Messages.Add( "GW.Message.mai l",
    egwDraft)
    >
    ' Create the message
    With gwnewmessage
    With .Recipients
    ' Add the To recipient(s) to the message
    If (strTo <"") Then
    '.Add strTo
    .Add strTo, NGW, egwTo
    End If
    ' Add the CC recipient(s) to the message
    If (strCC <"") Then
    .Add strCC, NGW, egwCC
    End If
    ' Add the BCC recipient(s) to the message
    If (strBCC <"") Then
    .Add strBCC, NGW, egwBC
    End If
    End With
    >
    ' Set the Subject, Body, and Importance of the message
    .Subject = strSubject
    .BodyText = strBody
    .Priority = egwHigh
    >
    ' Add attachments to the message.
    If (strAttachPathF ile <"") Then
    .Attachments.Ad d strAttachPathFi le, egwFile
    End If
    >
    ' Should we display the message before sending?
    If DisplayMsg Then
    ' Display message to user
    MessageId = .MessageId
    Set GWCom = CreateObject("G roupwiseCommand er")
    GWCom.Execute "ItemOpen (""" & MessageId & """)", RetStr
    GWCom.Execute "ItemSetTex t (""X00"";To! ; """ & strTo & """; 0)",
    RetStr
    Else
    .Send
    End If
    >
    End With
    >
    SendGWMail = True
    Set gwnewmessage = Nothing
    >
    End Function

    Comment

    • Tony Toews [MVP]

      #3
      Re: AccessXP/Groupwise fix

      bobh <vulcaned@isp.c omwrote:
      >Below is a function I want to use in AccessXP, it works as is but as
      >the comment says I need to manually open Tools - References and check
      >off 'Groupware Type Library' and I'm hoping someone here can show me
      >some sample code so I do not have to do that manually.
      Late binding means you can safely remove the reference and only have an error when
      the app executes lines of code in question. Rather than erroring out while starting
      up the app and not allowing the users in the app at all. Or when hitting a mid, left
      or trim function call.

      You'll want to install the reference if you are programming or debugging and want to
      use the object intellisense while in the VBA editor. Then,. once your app is
      running smoothly, remove the reference and setup the late binding statements.

      Sample code:
      ' Declare an object variable to hold the object
      ' reference. Dim as Object causes late binding.
      Dim objWordDoc As Object
      Set objWordDoc = CreateObject(" Word.Document")

      For more information including additional text and some detailed links see the "Late
      Binding in Microsoft Access" page at http://www.granite.ab.ca/access/latebinding.htm

      Tony
      --
      Tony Toews, Microsoft Access MVP
      Please respond only in the newsgroups so that others can
      read the entire thread of messages.
      Microsoft Access Links, Hints, Tips & Accounting Systems at

      Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

      Comment

      Working...