Consulting

Results 1 to 3 of 3

Thread: Excel Send Macro for Groupwise

  1. #1

    Excel Send Macro for Groupwise

    I found the following send macro for Groupwise and I am having some troubles with it.

    [VBA]
    Option Explicit
    Private ogwApp As GroupwareTypeLibrary.Application
    Private ogwRootAcct As GroupwareTypeLibrary.account

    Sub Email_Multiple_Users_Via_Groupwise()
    'Macro purpose: To stand as a self contained procedure for creating and
    'sending an email to multiple users (if required)

    'This code requires:
    ' -A reference to the Groupware Type Library
    ' -The following 2 lines declared at the beginning of the MODULE:
    ' Private ogwApp As GroupwareTypeLibrary.Application
    ' Private ogwRootAcct As GroupwareTypeLibrary.account
    ' -The following named ranges on the spreadsheet
    ' Email_To
    ' Email_CC
    ' Email_BC

    'SECTION 1
    'Declare all required variables

    Const NGW$ = "NGW"
    Dim ogwNewMessage As GroupwareTypeLibrary.Mail
    Dim StrLoginName As String, _
    StrMailPassword As String, _
    StrSubject As String, _
    StrBody As String, _
    strAttachFullPathName As String, _
    sCommandOptions As String, _
    cl As Range

    'SECTION 2
    'Set all required variables

    StrLoginName = "GroupwiseMailboxName" 'Enter your mailbox ID here
    StrMailPassword = "" 'A true password is not required
    StrSubject = "Subject goes here"
    StrBody = "Body of message goes here" & vbCrLf & _
    "Sent at " & Now()
    strAttachFullPathName = "" 'Put full path of workbook to be attached between quotes.

    'SECTION 3
    'Create the Groupwise object and login in to Groupwise

    'Set application object reference if needed
    If ogwApp Is Nothing Then 'Need to set object reference
    DoEvents
    Set ogwApp = CreateObject("NovellGroupWareSession")
    DoEvents
    End If

    If ogwRootAcct Is Nothing Then 'Need to log in
    'Login to root account
    If Len(StrMailPassword) Then 'Password was passed, so use it
    sCommandOptions = "/pwd=" & StrMailPassword
    Else 'Password was not passed
    sCommandOptions = vbNullString
    End If

    Set ogwRootAcct = ogwApp.Login(StrLoginName, sCommandOptions, _
    , egwPromptIfNeeded)
    DoEvents

    End If

    'SECTION 4
    'Create and Send the Message

    'Create new message
    Set ogwNewMessage = ogwRootAcct.WorkFolder.Messages.Add _
    ("GW.MESSAGE.MAIL", egwDraft)
    DoEvents

    'Assign "To" recipients
    For Each cl In ActiveSheet.Range("Email_To")
    If Not cl.Value = "" Then ogwNewMessage.Recipients.Add cl.Value, NGW, egwTo
    Next cl

    'Assign "CC" recipients
    For Each cl In ActiveSheet.Range("Email_CC")
    If Not cl.Value = "" Then ogwNewMessage.Recipients.Add cl.Value, NGW, egwCC
    Next cl

    'Assign "BC" recipients
    For Each cl In ActiveSheet.Range("Email_BC")
    If Not cl.Value = "" Then ogwNewMessage.Recipients.Add cl.Value, NGW, egwBC
    Next cl

    With ogwNewMessage
    'Assign the SUBJECT text
    If Not StrSubject = "" Then .Subject = StrSubject

    'Assign the BODY text
    If Not StrBody = "" Then .BodyText = StrBody

    'Assign Attachment(s)
    If Not strAttachFullPathName = "" Then .Attachments.Add strAttachFullPathName

    'Send the message
    On Error Resume Next
    'Send method may fail if recipients don't resolve
    .Send
    DoEvents
    On Error Goto 0
    End With

    'SECTION 5
    'Release all variables
    Set ogwNewMessage = Nothing
    Set ogwRootAcct = Nothing
    Set ogwApp = Nothing
    DoEvents
    End Sub
    [/VBA]

    My first question is will I need a new Macro since the Groupwise I am using is version 7.0? When I run the macro it seems to stop immediately at the first portion where it says "Dim ogwNewMessage As GroupwareTypeLibrary.Mail ". Do you know why that is?

  2. #2
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    My guess would be that you need to turn on a reference.

    In the VBE, go to Tools --> References and look for the Groupware Type Library and make sure that it is checked.


    Hope this helps.




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  3. #3
    VBAX Newbie
    Joined
    Jan 2009
    Posts
    4
    Location
    Hi,
    I have used this code to send an attached workbook via groupwise 7 and it worked perfectly.
    My company has upgraded to groupwise 8, and for some reason it will no longer attach the workbook... it comes up with an automation error. Placing On error goto next before the attachments.ad line of code it sends the email with all the CC and BC fields fine. ANYBODY got any clues why this should be so ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •