Our company is kinda backwards and still uses a GroupWise email server. Unfortunately, I was recently required to write some code
to send emails via this system. I was constrained to use VB .NET (which I'm not really wild about) I only managed to find one thing on the net about sending emails via GroupWise (Send GroupWise Email in .NET) and I found it was written in a structured format, when all that I actually wanted was to have an email class. So I took the information from there and created a class that has a plugin for the groupwise part (so when the company decides to move into the 21st century with a real mail server, I don't need to change much code at all).
Here comes the code:
' This class was written by Andrew Bowden for CIM on the 24th of May 2006
' This class is pretty specific, it is designed to send an email! It is also pretty stolen
' (when I say stolen, I mean borrowed) from http://www.ipdg3.com/sourcecode.php
' The title of this article was "Send GroupWise Email in .NET". I'm sorry that I haven't put a
' real link in here but I lost it - just found it again ;0
' http://www.ipdg3.com/sourcecoderesults.php?option=search_sourcecode&sc=NET_&ss=groupwise&match=cp&offset=0
' Anyway, I've embedded this into a class so that if our company ever gets off it's lazy
' ass and joins the rest of the IT community in the 21st century and install a SMTP server, I'll only
' need to modify this class to make everything work - God Bless OOP!
' Last Modified: Andrew Bowden
' Last Modified on: 24th May 2006
' Last Modification: Added all of these lovely comments, so I guess you must be happy!
Imports System
Imports System.Security
Public Class email
Private objMessages As Object
Private objMessage As Object
Private objMailBox As Object
Private objRecipients As Object
Private objRecipient As Object
Private objMessageSent As Object
Private objGroupWise As Object
Private objAccount As Object
'constructor
Public Sub New()
' Set some of the variables
objGroupWise = CreateObject("NovellGroupWareSession")
objAccount = objGroupWise.Login
End Sub
' This is a wrapper, so that if we ever change to a 'real' mail server
' (for example, SMTP) all that needs to be done is to write a SMTP method
' and redirect this part!
Public Function sendEmail(ByVal emailTo As String, ByVal subject As String, ByVal message As String) As Boolean
If emailTo.Length < 1 Or emailTo.IndexOf("@") < 0 Then
Return False
ElseIf subject.Length < 1 And message.Length < 1 Then
Return False
End If
Return sendGroupWiseEmail(emailTo, subject, message)
End Function
' Send an email via groupwise. Hopefully, it will return true for a successful send and False for a
' unsuccessful send.
Private Function sendGroupWiseEmail(ByVal emailTo, ByVal subject, ByVal message) As Boolean
Try
objMailBox = objAccount.mailbox
objMessages = objMailBox.Messages
objMessage = objMessages.Add("GW.MESSAGE.MAIL", "Draft")
objRecipients = objMessage.Recipients
objRecipient = objRecipients.Add(emailTo)
objMessage.Subject = subject
objMessage.BodyText = message
objMessageSent = objMessage.Send
Return True
Catch ex As Exception
' MessageBox.Show(ex.ToString)
Return False
Finally
Beep()
End Try
End Function
End Class
In order to instantiate and use this class, you need to call it with the following:
Dim e As email
e = New email
e.sendEmail(<email address>, <subject>, <body>)
And I hope that works for anyone else that needs to use it.
Popularity: 21% [?]


Thanks for posting this script! Save me some work!
Hello
Thanks for solution .Can you help me out I am pretty newbie.We are tring to send email from vb.net to Groupwise server .From diff articles on web I came
to know that in order to work this program we need to install gwcma1.dll under c:\novell group.Can you please guid me step by step what needs to install
to work this code. I’m getting exception Cannot create Active X component on this line of code- objGroupWise = CreateObject(”NovellGroupWareSession”)
is it b’cause dll(gwcma1.dll ) not registered?
Waiting for reply
Many Thanks
Meenal
It’s been a while and I’m no longer working in a situation where I have access to a groupwise server. However, I seem to remember one caveat of this was that the server needs to be running a groupwise client.
For example, this was running on SQL Server 2000 as a DTS package and the only way that it worked was that the groupwise client was running on the server (bad form I know!), alternatively you could do something like run the DTS package from a machine that has groupwise installed, but in that situation you need to make sure that you are running the package locally.
For your situation, I think that you might try removing and reinstalling the client to see if that works. From memory, I think that the client that I used was quite old (Novell 8?)
Andrew
Thank you so much for your class… helped me more than you realise!!!!!!
greatest commenting I’ve seen in a long time.
Thankyou very much for the comment Michael, it’s always nice to feel appreciated!
Andrew