Excel

Send email using Novell's Groupwise 5.5 (or above)

Ease of Use

Intermediate

Version tested with

XL 97 & 2003, Groupwise 5.5, 6 

Submitted by:

Ken Puls

Description:

This is a stand alone procedure to send email (to multiple users if desired) using Novell's Groupwise 5.5 or above. 

Discussion:

Many times when Groupwise is installed, systems administrators deliberately turn off Groupwise mail integration with Microsoft Office. Unfortunately, this can also stop the Sendmail object from functioning as well. This procedure allows a user to send mail using groupwise, directly from Excel. It can even be modified to attach several workbooks using a loop - although that particular coding is not covered here. Please post in the Excel help forum if you need help doing this. (FYI, if Groupwise is integrated with Office, the default save directories for Office program's become Groupwise's document libraries, which is not always desired, hence the reason most systems administrators disable the Office integration.) 

Code:

instructions for use

			

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

How to use:

  1. Copy above code.
  2. In Excel press Alt + F11 to enter the VBE.
  3. Press Ctrl + R to show the Project Explorer.
  4. Right-click desired file on left (in bold).
  5. Choose Insert -> Module.
  6. Paste code into the right pane.
  7. From the Tools Menu (in the VBE), choose References.
  8. Find the reference to "Groupware Type Library" and check the box, and click OK.
  9. Press Alt + Q to close the VBE.
  10. Save workbook before any other changes.
  11. Create 3 (multicell) named ranges on the worksheet (Insert|Name|Define), and assign them the names: "Email_To", "Email_CC" and "Email_BC"
 

Test the code:

  1. Enter at least one email address in the "Email_To" range, and others in the other fields if/as desired.
  2. Press Alt + F8.
  3. Choose 'Email_Multiple_Users_Via_Groupwise'.
  4. Press 'Run'.
  5. Check your sent items folder in Groupwise to verify that the emails have been sent.
 

Sample File:

Groupwise Code.zip 10KB 

Approved by Jacob Hilderbrand


This entry has been viewed 151 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express