Option Explicit
Private ogwApp As GroupwareTypeLibrary.Application
Private ogwRootAcct As GroupwareTypeLibrary.account
Sub Email_Multiple_Users_Via_Groupwise()
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
StrLoginName = "GroupwiseMailboxName"
StrMailPassword = ""
StrSubject = "Subject goes here"
StrBody = "Body of message goes here" & vbCrLf & _
"Sent at " & Now()
strAttachFullPathName = ""
If ogwApp Is Nothing Then
DoEvents
Set ogwApp = CreateObject("NovellGroupWareSession")
DoEvents
End If
If ogwRootAcct Is Nothing Then
If Len(StrMailPassword) Then
sCommandOptions = "/pwd=" & StrMailPassword
Else
sCommandOptions = vbNullString
End If
Set ogwRootAcct = ogwApp.Login(StrLoginName, sCommandOptions, _
, egwPromptIfNeeded)
DoEvents
End If
Set ogwNewMessage = ogwRootAcct.WorkFolder.Messages.Add _
("GW.MESSAGE.MAIL", egwDraft)
DoEvents
For Each cl In ActiveSheet.Range("Email_To")
If Not cl.Value = "" Then ogwNewMessage.Recipients.Add cl.Value, NGW, egwTo
Next cl
For Each cl In ActiveSheet.Range("Email_CC")
If Not cl.Value = "" Then ogwNewMessage.Recipients.Add cl.Value, NGW, egwCC
Next cl
For Each cl In ActiveSheet.Range("Email_BC")
If Not cl.Value = "" Then ogwNewMessage.Recipients.Add cl.Value, NGW, egwBC
Next cl
With ogwNewMessage
If Not StrSubject = "" Then .Subject = StrSubject
If Not StrBody = "" Then .BodyText = StrBody
If Not strAttachFullPathName = "" Then .Attachments.Add strAttachFullPathName
On Error Resume Next
.Send
DoEvents
On Error GoTo 0
End With
Set ogwNewMessage = Nothing
Set ogwRootAcct = Nothing
Set ogwApp = Nothing
DoEvents
End Sub
|