Solved

send email with attachments

Posted on 2004-04-13
45
1,339 Views
Last Modified: 2008-05-02
I want to be able to send an email with attachment from Access using VBA.

I use Groupwise and can send multiple attachments OK using VBA using the groupwise class on the access web (http://www.mvps.org/access/modules/mdl0059.htm).  What I want to be able to do is not actually send the email but just open (show) the email with the attachment(s) and the subject / message filled out.  At this point I don't know the recipients address(es), so I want to show the email so that the user can use addresses from the groupwise address book.  This is the bit I am having trouble with.

Any Ideas?
0
Comment
Question by:ShaneDavidson
  • 25
  • 8
  • 7
  • +3
45 Comments
 
LVL 34

Expert Comment

by:flavo
Comment Utility
see http://examples.oreilly.com/accesscook/CDROM/

d/l chapter 5, and see 05-01.mdb i think..

Has an exapmle of how to get printer names

0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
woops wrong Q
0
 
LVL 32

Expert Comment

by:jadedata
Comment Utility
Greetings ShaneDavidson!

  I am currently using vbSendMail.dll.  This works like a champ!

 http://www.freevbcode.com/ShowCode.Asp?ID=109

regards
jack
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
take out these lines

 ' .SendMessage strTemp
  '.DeleteMessage strTemp, True

and it sits in your Work in Progress folder for you waiting
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
hmmm... the addresses you pass it disapear....

Not sure why, prob best to go Jakes way then
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
>>  At this point I don't know the recipients address(es),

Then maybe my way isnt that bad after all
0
 
LVL 32

Expert Comment

by:jadedata
Comment Utility
mines not looking good either...
and MS doesn't really like to integrate with Novell
0
 
LVL 32

Expert Comment

by:jadedata
Comment Utility
Shane:
you might want to post a minimum point link in the Groupwise TA to this quesiton.  
Put the address to this question in it so those Experts know where to go.
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
>> MS doesn't really like to integrate with Novell

Sure doesnt!

Its a pian in the batty!
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
Maybe i could rangle some code to open all emails waiting in the WIP area, or even the last one to go in there and tack it on the end if you want??  I have the advantage / disadvantage of also having GW
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
Here's my idea

1. Create email - Done
2. Put email in WIP - Done
3. Open in GW last email put in WIP area - Can be done

You want???

0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
have a look at this - sending mails thru groupwise

http://www.mvps.org/access/modules/mdl0059.htm
0
 
LVL 1

Author Comment

by:ShaneDavidson
Comment Utility
Thanks flavo,  that sound's like it will work, not the most elegant but I don't mind that.  Yes, I would appreciate the code.  
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
rocki,

that's where we started..
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
sorry, not reading properly, time for a change of specs I think
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
ok, try the .Display method, in outlook automation thats what is used to display the message

nothing to set, just

<object>.Display (or just .Display when using with)
0
 
LVL 1

Author Comment

by:ShaneDavidson
Comment Utility
jadedata, I had a look at your vbSendMail but it probably won't work for me, I don't have VB6, and also the database is multi user (~20) so I don't want to have to register a dll on each machine - which I assume I'll need to do.
0
 
LVL 1

Author Comment

by:ShaneDavidson
Comment Utility
rockiroads,

I don't have outlook and .Display is not a supported method for Groupwise (GroupwareTypeLibrary) - I get an error that this method is not supported.
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
difficult to test here without having GroupWise, I thought it might be worth a try

can I suggest then that you go into the object browser, search for your library and see what methods are available

0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
This is harder than i thought... I can loop through an get the last email in the WIP area, but i still dont see the open method...  Like yuo said.. Ill play around a little more
0
 
LVL 1

Author Comment

by:ShaneDavidson
Comment Utility
A display / show method is exactly what I want - I just can't seem to find one, I have looked through the object library but can't find anything.  If someone could give me just the method name it would be an easy 500 points, but I can't see one and flavo seems to be having the same problem.
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
I thought the object browser would of helped actually, pity
Im a bit stuck here 'cos I dont have groupwise
pity
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 34

Expert Comment

by:flavo
Comment Utility
nothing in the Obj Browser!  this blows!
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
I found this, looks remarkably like outlook automation, except like u said, its missing .Display
perhaps its not supported
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
Found a goob book.

This code works
Sub test()

Dim GW As Variant
Dim Acc As Variant
Dim MyMailFolder As Variant
Dim MyMessages As Variant
Dim MyMessage As Variant
Dim MyDraftMsg As Variant
Dim MyRecips As Variant
Dim MyRecip As Variant
Dim SenderDisplayName As String
Dim SenderEmailAddress As String
Dim CreationDate As Date
Dim iCount As Integer
Dim vCommander As Variant
Dim ParamStr As String
Dim MyMsgID As String
Dim sResult As String
Dim iRet As Integer
'C h a p t e r 4 69
Set GW = CreateObject("NovellGroupWareSession")
Set Acc = GW.Login
Set MyMailFolder = Acc.MailBox
Set MyMessages = MyMailFolder.Messages
' How many messages are there?
iCount = MyMessages.Count
' Incorrect method. Doesn’t give any subject, recipients, etc.
' SenderDisplayName = "John Doe"
' SenderEmailAddress = "jdoe.GWPost.GWDomain"
' SenderEmailAddressType = "NGW"
' CreationDate = "12/25/2000 8:00:00 AM"
' Set MyMessage = MyMessages.AddExistingMessage(SenderDisplayName, ‘ ‘
' SenderEmailAddress, SenderEmailAddressType, CreationDate, egwIncoming,
' egwMessageDelivered, egwNormal, egwDefaultSecurity)
' Correct method. Use a draft message.
Set MyDraftMsg = MyMessages.Add("GW.MESSAGE.MAIL")
MyDraftMsg.Subject = "My Subject"
MyDraftMsg.BodyText = "Adding a new message without sending it"
MyDraftMsg.FromText = Acc.RootFolder.Name
Set MyRecips = MyDraftMsg.Recipients
Set MyRecip = MyRecips.AddByDisplayName("Mary Doe")
Set MyRecip = MyRecips.AddByDisplayName("Fu Ling Yu")
Set MyRecip = MyRecips.AddByDisplayName("Santa Claus")
SenderDisplayName = "John Doe"
SenderEmailAddress = "jdoe.GWPost.GWDomain"
SenderEmailAddressType = ""
CreationDate = "12/25/2000 8:00:00 AM"
Set MyMessage = MyMessages.AddExistingMessage(SenderDisplayName, SenderEmailAddress, SenderEmailAddressType, CreationDate, egwIncoming, egwMessagePrivate, egwNormal, egwDefaultSecurity, MyDraftMsg)
MyMailFolder.Refresh
Set MyMessages = Nothing
Set MyMessages = MyMailFolder.Messages
' This value should be one more than it was before
iCount = MyMessages.Count
' Open the new message to view it
MyMsgID = MyMessage.MessageID
Set vCommander = CreateObject("GroupWiseCommander")
ParamStr = "ItemOpen(""" + MyMsgID + """)"
iRet = vCommander.Execute(ParamStr, sResult)
End Sub
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
Found a good book.

0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
see developer.novell.com/research/ebooks/GWDevGuide.pdf

Page 69!
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
its a great book!

Wish i had found it before!
0
 
LVL 1

Author Comment

by:ShaneDavidson
Comment Utility
I can't seem to get the link developer.novell.com/research/ebooks/GWDevGuide.pdf
to show anything - do you need to login or something?

The code you gave me creates a message to me (not from me) ie shows up in the inbox?
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
take out these lines

'SenderDisplayName = "John Doe"
'SenderEmailAddress = "jdoe.GWPost.GWDomain"

0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
>>  to show anything - do you need to login or something?

Come to think of it, i did that a few days ago, so maybe you do??

Ill post the pdf somewhere for you
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
http://sustomers.tripod.com/GWDevGuide.pdf

Should be there in a minute or so, just u/l it now
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
good to go.
Enjoy
0
 
LVL 1

Author Comment

by:ShaneDavidson
Comment Utility
Thanks,  I got the link developer.novell.com/research/ebooks/GWDevGuide.pdf
to work after all - it just took about 15 minutes to open.

I took out the lines:
'SenderDisplayName = "John Doe"
'SenderEmailAddress = "jdoe.GWPost.GWDomain"

unfortunately all this does is makes the from address me (the default), it is still an email ithat has been sent to my inbox - not a new email waiting to be sent

I'll have a look through the book to see what I can find
0
 
LVL 5

Expert Comment

by:Emanon_Consulting
Comment Utility
Hi ShaneDavidson,

I have a friend in one of our local Ministries that was looking for a way to send email using GroupWise.
Here is the code that I found and forwarded on to him.  It seemed to be a solution for him and I hope it is helpful to you.
It comes from an MS Access 97 file but I know that my friend was using 2000 and it seemed to work fine for him.

Sorry for all the code...  I don't remember what website I found the sample application and I haven't got time to search for it right now otherwise I would just post the link.

Create a New Module called "basGWDemo"  and paste this code

'*****Start of Code******
Option Compare Database
Option Explicit

Sub RunDemo()
'this is a sample usage routine
On Error GoTo Err_Handler
Dim strTemp As String
Dim varAttach(1) As Variant
Dim strRecTo(1, 0) As String
Dim lngCount As Long
Dim varProxies As Variant
Dim cGW As GW

varAttach(0) = "c:\command.com"
varAttach(1) = "c:\windows\readme.txt"

strRecTo(0, 0) = "foo@foo.invalid"
strRecTo(1, 0) = "Full Name 1"

Set cGW = New GW
With cGW
  .Login
  .BodyText = "body"
  .Subject = "subj"
  .RecTo = strRecTo
  .FileAttachments = varAttach
  .FromText = "FromText"
  .Priority = "High"
  strTemp = .CreateMessage
  .ResolveRecipients strTemp
  If IsArray(.NonResolved) Then MsgBox "Some unresolved recipients."
  .SendMessage strTemp
  .DeleteMessage strTemp, True
End With

Exit_Here:
  Set cGW = Nothing
  Exit Sub

Err_Handler:
  MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical
  Resume Exit_Here

End Sub

'****End of Code******


Create a New Class Module called "GW" and paste this code

'*****Start of Code******
Option Compare Database
Option Explicit
Option Base 0
'code by Dimitri Furman <dfurman@cloud9.net>, unless otherwise noted
'last modified on 7/22/2002

Private mobjGWApp As Object
Private mobjGWAcct As Object

'late binding currently used
'early binding declares commented out throughout the module.
'GWCMA1.DLL is the GW typelib.
'tested with Groupwise 5.2.4 - 5.2.6

'Dim mobjGWApp As GroupwareTypeLibrary.Application
'Dim mobjGWAcct As GroupwareTypeLibrary.Account

Private mstrFromText As String 'GW will always append the account owner's name to this
Private mstrSubject As String 'up to 100 chars
Private mstrBodyText As String
Private mintPriority As Integer
Private mastrRecTo() As String 'mastrRecTo(0, i)=address; mastrRecTo(1, i)=display name
Private mastrRecCc() As String 'mastrRecCc(0, i)=address; mastrRecCc(1, i)=display name
Private mastrRecBc() As String 'mastrRecBc(0, i)=address; mastrRecBc(1, i)=display name
Private mastrFileAttachments() As String 'string array of paths
Private mastrNonResolved() As String 'array of non-resolved recipients if any

Private Const mconDefaultFolder = "Work In Progress" 'name of folder to create draft messages in if none other specified
Private Const mconEmailType = "NGW" 'should be something else for external(?) email
Private Const mconSystemAddrBookName = "Novell GroupWise Address Book" 'can be renamed?

'GW typelib's constants, defined here because of late binding being used
Private Const egwLow = 1
Private Const egwNormal = 2
Private Const egwHigh = 3
Private Const egwTo = 0
Private Const egwCC = 1
Private Const egwBC = 2
Private Const egwResolved = 3
Private Const egwDraft = 4
Private Const egwFile = 1
Private Const egwUser = 1
Private Const egwResource = 3

Private Const mconERR_GW_NOT_INSTALLED = vbObjectError Or 1000
Private Const mconERR_LOGIN_UNSUCCESSFUL = vbObjectError Or 1001
Private Const mconERR_BAD_MESSAGE_ID = vbObjectError Or 1002
Private Const mconERR_COULD_NOT_DELETE = vbObjectError Or 1003
Private Const mconERR_COULD_NOT_SEND = vbObjectError Or 1004
Private Const mconERR_NO_RECIPIENTS = vbObjectError Or 1005
Private Const mconERR_BAD_FOLDER_NAME = vbObjectError Or 1006
Private Const mconERR_BAD_REC_ARRAY = vbObjectError Or 1007
Private Const mconERR_BAD_ATTACHMENTS_ARRAY = vbObjectError Or 1008
Private Const mconERR_NO_TO_RECIPIENTS = vbObjectError Or 1009
Private Const mconERR_MSG_NOT_A_DRAFT = vbObjectError Or 1010
Private Const mconERR_COULD_NOT_PROXY = vbObjectError Or 1011

#Const VBA5 = True 'True for Access 97, False for VB or VBA6
#Const Access = True 'True for Access any version, False for VB
'For example, in Access 2000 and later use VBA5=False, Access=True

#If Access Then
  Private mintErrTrapping As Integer
#End If

#If VBA5 Then
#Else
  Public Event GWStatus(ByVal strStatusMessage As String)
  Public Enum GWPriority
    LowPriority = egwLow
    NormalPriority = egwNormal
    HighPriority = egwHigh
  End Enum
#End If

'UNC code in this class was originally written by Terry Kreft
'and Dev Ashish.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
' Original Code by Terry Kreft
' Modified by Dev Ashish
'
'Drive Types
Private Const DRIVE_UNKNOWN = 0
Private Const DRIVE_ABSENT = 1
Private Const DRIVE_REMOVABLE = 2
Private Const DRIVE_FIXED = 3
Private Const DRIVE_REMOTE = 4
Private Const DRIVE_CDROM = 5
Private Const DRIVE_RAMDISK = 6
' returns errors for UNC Path
Private Const ERROR_BAD_DEVICE = 1200&
Private Const ERROR_CONNECTION_UNAVAIL = 1201&
Private Const ERROR_EXTENDED_ERROR = 1208&
Private Const ERROR_MORE_DATA = 234
Private Const ERROR_NOT_SUPPORTED = 50&
Private Const ERROR_NO_NET_OR_BAD_PATH = 1203&
Private Const ERROR_NO_NETWORK = 1222&
Private Const ERROR_NOT_CONNECTED = 2250&
Private Const NO_ERROR = 0

Private Declare Function WNetGetConnection Lib "mpr.dll" Alias _
        "WNetGetConnectionA" (ByVal lpszLocalName As String, _
        ByVal lpszRemoteName As String, cbRemoteName As Long) As Long
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias _
    "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, _
    ByVal lpBuffer As String) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" _
    (ByVal nDrive As String) As Long


Private Sub GW_Status(strStatusMessage As String)
On Error Resume Next

#If VBA5 Then
  Select Case strStatusMessage
    Case vbNullString
      SysCmd acSysCmdClearStatus
    Case Else
      SysCmd acSysCmdSetStatus, strStatusMessage
  End Select
#Else
  RaiseEvent GWStatus(strStatusMessage)
#End If

End Sub


Private Property Get GWApp() As Object
On Error GoTo ErrHandler

If mobjGWApp Is Nothing Then _
  Set mobjGWApp = CreateObject("NovellGroupWareSession")

Set GWApp = mobjGWApp

ExitHere:
  Exit Property
 
ErrHandler:
  Select Case Err.Number
    Case 429
      Err.Raise mconERR_GW_NOT_INSTALLED, "GW::Initialize", "Groupwise is not installed or is not registered on this computer."
    Case Else
      Err.Raise Err.Number, Err.Source, Err.Description
  End Select
  Resume ExitHere
 
End Property



Private Function ValidateAttachArray(varAttachArray As Variant) As Boolean
Dim varTemp As Variant

On Error Resume Next
varTemp = varAttachArray(LBound(varAttachArray, 1))
'the array has to be exactly 1-dim
If Not (Err.Number > 0) Then ValidateAttachArray = True
Err.Clear

End Function

Private Function ValidateRecArray(varRecArray As Variant) As Boolean
On Error GoTo ErrHandler
Dim varTemp As Variant

On Error Resume Next
varTemp = varRecArray(LBound(varRecArray, 1), LBound(varRecArray, 2))
'the array has to be exactly 2-dim and ...
If Err.Number > 0 Then
  Err.Clear
  GoTo ExitHere
Else
  On Error GoTo ErrHandler
  If Not (LBound(varRecArray, 1) = 0 And _
    UBound(varRecArray, 1) = 1) Then GoTo ExitHere
  '... the first dimension has to be 0 To 1
  ValidateRecArray = True
End If

ExitHere:
  Exit Function

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere
 
End Function

Private Sub AddRecipients(objMsg As Object)
'adds recipients from arrays to a message, deletes those that cannot be resolved
On Error GoTo ErrHandler
Dim objRecipient As Object
'Dim objRecipient As GroupwareTypeLibrary.Recipient
Dim intCount As Integer, intCount2 As Integer

For intCount = 0 To UBound(mastrRecTo, 2)
  If Len(mastrRecTo(0, intCount)) > 0 Then 'there's an address
    Set objRecipient = objMsg.Recipients.Add(mastrRecTo(0, intCount), mconEmailType, egwTo)
    If Len(mastrRecTo(1, intCount)) > 0 Then objRecipient.DisplayName = mastrRecTo(1, intCount)
  Set objRecipient = Nothing
  End If
Next intCount
For intCount = 0 To UBound(mastrRecCc, 2)
  If Len(mastrRecCc(0, intCount)) > 0 Then 'there's an address
    Set objRecipient = objMsg.Recipients.Add(mastrRecCc(0, intCount), mconEmailType, egwCC)
    If Len(mastrRecCc(1, intCount)) > 0 Then objRecipient.DisplayName = mastrRecCc(1, intCount)
    Set objRecipient = Nothing
  End If
Next intCount
For intCount = 0 To UBound(mastrRecBc, 2)
  If Len(mastrRecBc(0, intCount)) > 0 Then 'there's an address
    Set objRecipient = objMsg.Recipients.Add(mastrRecBc(0, intCount), mconEmailType, egwBC)
    If Len(mastrRecBc(1, intCount)) > 0 Then objRecipient.DisplayName = mastrRecBc(1, intCount)
    Set objRecipient = Nothing
  End If
Next intCount
 
If UBound(mastrNonResolved) > 0 Then ReDim mastrNonResolved(0) 'in case .ResolveRecipients have been called before .SendMessage
For intCount = objMsg.Recipients.Count To 1 Step -1
  On Error Resume Next
  objMsg.Recipients(intCount).Resolve
  On Error GoTo ErrHandler
  If Not (objMsg.Recipients(intCount).Resolved = egwResolved) Then
    ReDim Preserve mastrNonResolved(intCount2)
    mastrNonResolved(intCount2) = objMsg.Recipients(intCount).EmailAddress
    intCount2 = intCount2 + 1
    objMsg.Recipients(intCount).Delete
  End If
Next intCount

ExitHere:
  On Error Resume Next
  Set objRecipient = Nothing
  Exit Sub

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Sub

Private Function fGetUNCPath(strDriveLetter As String) As String
    On Local Error GoTo fGetUNCPath_Err

    Dim Msg As String, lngReturn As Long
    Dim lpszLocalName As String
    Dim lpszRemoteName As String
    Dim cbRemoteName As Long
    lpszLocalName = strDriveLetter
    lpszRemoteName = String$(255, vbNullChar)
    cbRemoteName = Len(lpszRemoteName)
    lngReturn = WNetGetConnection(lpszLocalName, lpszRemoteName, _
                                       cbRemoteName)
    Select Case lngReturn
        Case ERROR_BAD_DEVICE
            Msg = "Error: Bad Device"
        Case ERROR_CONNECTION_UNAVAIL
            Msg = "Error: Connection Un-Available"
        Case ERROR_EXTENDED_ERROR
            Msg = "Error: Extended Error"
        Case ERROR_MORE_DATA
               Msg = "Error: More Data"
        Case ERROR_NOT_SUPPORTED
               Msg = "Error: Feature not Supported"
        Case ERROR_NO_NET_OR_BAD_PATH
               Msg = "Error: No Network Available or Bad Path"

        Case ERROR_NO_NETWORK
               Msg = "Error: No Network Available"
        Case ERROR_NOT_CONNECTED
               Msg = "Error: Not Connected"
        Case NO_ERROR
               ' all is successful...
    End Select
    If Len(Msg) Then
        MsgBox Msg, vbInformation
    Else
        'fGetUNCPath = Left$(lpszRemoteName, cbRemoteName)
        'the above will work only if the buffer is filled with spaces, and the API simply
        'inserts the null-terminated UNC path at the beginning of the buffer, which can be right trimmed.
        'That seems to be not the case on NT4, there is something else in the buffer
        'after the first null, so we need to explicitly trim it at the first null char.
        fGetUNCPath = Left$(lpszRemoteName, InStr(1, lpszRemoteName, vbNullChar, vbBinaryCompare) - 1)
    End If
fGetUNCPath_End:
    Exit Function
fGetUNCPath_Err:
    MsgBox Err.Description, vbInformation
    Resume fGetUNCPath_End
End Function

Private Function fDriveType(strDriveName As String) As String
    Dim lngRet As Long
    Dim strDrive As String
    lngRet = GetDriveType(strDriveName)
    Select Case lngRet
        Case DRIVE_UNKNOWN 'The drive type cannot be determined.
            strDrive = "Unknown Drive Type"
        Case DRIVE_ABSENT 'The root directory does not exist.
            strDrive = "Drive does not exist"
        Case DRIVE_REMOVABLE 'The drive can be removed from the drive.
            strDrive = "Removable Media"
        Case DRIVE_FIXED 'The disk cannot be removed from the drive.
            strDrive = "Fixed Drive"
        Case DRIVE_REMOTE  'The drive is a remote (network) drive.
            strDrive = "Network Drive"
        Case DRIVE_CDROM 'The drive is a CD-ROM drive.
            strDrive = "CD Rom"
        Case DRIVE_RAMDISK 'The drive is a RAM disk.
            strDrive = "Ram Disk"
    End Select
    fDriveType = strDrive
End Function


Public Function IsFolder(strFolderID) As Boolean
On Error GoTo ErrHandler
Dim objFld As Object
Dim strTemp As String

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::IsFolder", "Could not login to Groupwise."

On Error Resume Next
Set objFld = mobjGWAcct.GetFolder(strFolderID)
On Error GoTo ErrHandler
'will get an object here if strFolderID is a valid MessageID

If Not (objFld Is Nothing) Then
  On Error Resume Next
  strTemp = objFld.Name 'a folder has a name, a message doesn't
  On Error GoTo ErrHandler
  If Len(strTemp) > 0 Then IsFolder = True
End If

ExitHere:
  On Error Resume Next
  Set objFld = Nothing
  Exit Function
 
ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Function

Public Function IsMessage(strMessageID) As Boolean
On Error GoTo ErrHandler
Dim objMsg As Object

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::IsMessage", "Could not login to Groupwise."

On Error Resume Next
Set objMsg = mobjGWAcct.GetMessage(strMessageID)
On Error GoTo ErrHandler

IsMessage = Not (objMsg Is Nothing)

ExitHere:
  On Error Resume Next
  Set objMsg = Nothing
  Exit Function
 
ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Function

Public Sub Reset()
'resets all message properties, prepares for a new message
On Error GoTo ErrHandler

mstrFromText = vbNullString
mstrSubject = vbNullString
mstrBodyText = vbNullString
mintPriority = egwNormal
InitArrays

GW_Status vbNullString

ExitHere:
  Exit Sub

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Sub

Public Sub ResolveRecipients(strMessageID As String)
'this *may* be called before SendMessage to see if there are any
'non-resolving recipients. If there are, get them from .NonResolved property
On Error GoTo ErrHandler
Dim objMsg As Object

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::ResolveRecipients", "Could not login to Groupwise."

Set objMsg = mobjGWAcct.GetMessage(strMessageID)
If objMsg Is Nothing Then
  Err.Raise mconERR_COULD_NOT_SEND, "GW::ResolveRecipients", "Could not get MessageID '" & strMessageID & "'."
  GoTo ExitHere
End If

AddRecipients objMsg

ExitHere:
  On Error Resume Next
  Set objMsg = Nothing
  Exit Sub
 
ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Sub

Public Function ValidateEmail(strEmail As String) As Boolean
'attempts to return True only if strEmail is a syntactically valid email address
On Error GoTo ErrHandler

If (strEmail Like "*?@?*.?*") And Not (strEmail Like "*@*@*") And Not (strEmail Like "*..*") And Not (strEmail Like "* *") And Not (strEmail Like "*.") Then _
  ValidateEmail = True

ExitHere:
  Exit Function

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Function

Public Property Let BodyText(strBodyText As String)
 
If Len(strBodyText) > 0 Then mstrBodyText = strBodyText & vbCrLf
'GW might cut off the last word without vbCrLf

End Property

Private Function ConvertToUNC(strFilePath As String) As String
On Error GoTo ErrHandler
Dim strDrive As String
Dim strDrivelessPath As String
Dim strUNCPath As String

If Not (Len(strFilePath) >= 2) Then 'at least need drive
  ConvertToUNC = strFilePath
  GoTo ExitHere
End If

If Not (StrComp(fDriveType(Left$(strFilePath, 2)), "Network Drive", vbTextCompare) = 0) Then
  ConvertToUNC = strFilePath
  GoTo ExitHere
End If

strDrive = Left$(strFilePath, 2)
strDrivelessPath = Mid$(strFilePath, 3)

strUNCPath = fGetUNCPath(strDrive)
'strUNCPath = Left$(Trim$(strUNCPath), Len(Trim$(strUNCPath)) - 1)
strUNCPath = strUNCPath & strDrivelessPath

If Len(Dir(strUNCPath, vbNormal) & Dir(strUNCPath, vbDirectory) & vbNullString) > 0 Then
  ConvertToUNC = strUNCPath
Else
  ConvertToUNC = strFilePath
End If

ExitHere:
  Exit Function

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Function

Public Function CreateFolder(strFolderName As String, Optional blnInCabinet As Boolean) As Variant
'creates a folder under root account or under Cabinet folder if blnInCabinet, returns FolderID
On Error GoTo ErrHandler
Dim objParentFlds As Object
Dim objFolder As Object
'Dim objParentFlds As GroupwareTypeLibrary.Folders
'Dim objFolder As GroupwareTypeLibrary.Folder

GW_Status "Creating folder"

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::CreateFolder", "Could not login to Groupwise."

If Not (Len(strFolderName) > 0) Then Err.Raise mconERR_BAD_FOLDER_NAME, "GW::CreateFolder", "Invalid folder name: '" & strFolderName & "'"

If blnInCabinet Then
  Set objParentFlds = mobjGWAcct.Cabinet.Folders
Else
  Set objParentFlds = mobjGWAcct.AllFolders
End If

Set objFolder = objParentFlds.Add(strFolderName)
CreateFolder = objFolder.FolderID

mobjGWAcct.Refresh

ExitHere:
  On Error Resume Next
  Set objFolder = Nothing
  Set objParentFlds = Nothing
  GW_Status vbNullString
  Exit Function

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Function

Public Sub DeleteMessage(strMessageID As String, Optional blnPurge As Boolean)
'sends a message to Trash by MessageID, no prompt
'optionally purges the message from message store
On Error GoTo ErrHandler
Dim objMsg As Object
Dim objTrashEntries As Object
'Dim objMsg As GroupwareTypeLibrary.Message
'Dim objTrashEntries As GroupwareTypeLibrary.TrashEntries
Dim lngCount As Long

GW_Status "Deleting message"

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::DeleteMessage", "Could not login to Groupwise."

Set objMsg = mobjGWAcct.GetMessage(strMessageID)
If objMsg Is Nothing Then
  Err.Raise mconERR_COULD_NOT_DELETE, "GW::DeleteMessage", "Could not delete MessageID '" & strMessageID & "'."
  GoTo ExitHere
End If

objMsg.Delete
objMsg.Parent.Refresh

If blnPurge Then
  Set objTrashEntries = mobjGWAcct.Trash.TrashEntries
  For lngCount = objTrashEntries.Count To 1 Step -1 'assume that the message being purged is likely to be at the top of the collection, so it's faster to go from the top
    If StrComp(objTrashEntries(lngCount).Message.MessageID, objMsg.MessageID, vbTextCompare) = 0 Then
      objTrashEntries(lngCount).Delete 'purge
      Exit For
    End If
  Next lngCount
End If

Me.RefreshAcct

ExitHere:
  On Error Resume Next
  Set objMsg = Nothing
  Set objTrashEntries = Nothing
  GW_Status vbNullString
  Exit Sub

ErrHandler:
  Select Case Err.Number
    Case -2147352567
      Err.Raise mconERR_BAD_MESSAGE_ID, "GW::DeleteMessage", "Invalid MessageID '" & strMessageID & "'."
    Case Else
      Err.Raise Err.Number, Err.Source, Err.Description
  End Select
  Resume ExitHere

End Sub

Public Property Let FileAttachments(varFileAttachments As Variant)
'accepts an array of file paths or single path, converts to UNC if network path
'no wildcards
On Error GoTo ErrHandler
Dim intCount As Integer
Dim intLBound As Integer
Dim strPath As String

If Not IsArray(varFileAttachments) Then 'assume single path submitted
  ReDim mastrFileAttachments(0)
  strPath = ConvertToUNC(varFileAttachments & vbNullString)
  If Len(Dir(strPath) & vbNullString) > 0 Then mastrFileAttachments(0) = strPath
Else
  If Not ValidateAttachArray(varFileAttachments) Then Err.Raise mconERR_BAD_ATTACHMENTS_ARRAY, "GW::FileAttachments", "Invalid attachments array."
  intLBound = LBound(varFileAttachments)
  For intCount = intLBound To UBound(varFileAttachments)
    strPath = ConvertToUNC(varFileAttachments(intCount - intLBound) & vbNullString)
    If Len(Dir(strPath) & vbNullString) > 0 Then
      ReDim Preserve mastrFileAttachments(intCount - intLBound) 'make it 0-based
      mastrFileAttachments(intCount - intLBound) = strPath
      'might get a ZLS array element here, that's OK
    End If
  Next intCount
End If

ExitHere:
  Exit Property

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Property

Public Property Let FromText(strFromText As String)
  mstrFromText = strFromText & Space(1)
End Property


Private Sub InitArrays()
On Error GoTo ErrHandler

Erase mastrRecTo, mastrRecBc, mastrRecBc, mastrFileAttachments, mastrNonResolved

ReDim mastrRecTo(1, 0)
ReDim mastrRecCc(1, 0)
ReDim mastrRecBc(1, 0)
ReDim mastrFileAttachments(0)
ReDim mastrNonResolved(0)

ExitHere:
  Exit Sub

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Sub

Public Property Get NonResolved() As Variant
'1-dim. array of non-resolved addresses for To, Cc, and Bc lists, if any; otherwise Null
'available after .AddRecipients
On Error GoTo ErrHandler

If Len(mastrNonResolved(0)) > 0 Then
  NonResolved = mastrNonResolved
Else
  NonResolved = Null
End If

ExitHere:
  Exit Property
 
ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Property

Public Property Get AcctOwner() As String
On Error GoTo ErrHandler
 
If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::AcctOwner", "Could not login to Groupwise."
 
AcctOwner = mobjGWAcct.Owner

ExitHere:
  Exit Property
 
ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Property

#If VBA5 Then
Public Property Let Priority(strPriority As String)
'priority doesn't stick to a draft message and is reset to Standard after Message.Refresh
On Error GoTo ErrHandler

Select Case LCase$(strPriority)
  Case "low"
    mintPriority = egwLow
  Case "high"
    mintPriority = egwHigh
  Case Else
    mintPriority = egwNormal
End Select
 
ExitHere:
    Exit Property
   
ErrHandler:
    Err.Raise Err.Number, Err.Source, Err.Description
    Resume ExitHere
 
End Property

#Else
Public Property Let Priority(ePriority As GWPriority)
'priority doesn't stick to a draft message and is reset to Standard after Message.Refresh
On Error GoTo ErrHandler

mintPriority = ePriority

ExitHere:
  Exit Property
 
ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Property
#End If

Public Property Let RecBc(varRecBc As Variant)
'accepts an array of Bc: recipients: varRecBc(0, i)=address; varRecBc(1, i)=display name
'or a single address
On Error GoTo ErrHandler
Dim intCount As Integer
Dim intLBound As Integer

If Not IsArray(varRecBc) Then 'assume single address with no display name
  ReDim mastrRecBc(1, 0)
  mastrRecBc(0, 0) = varRecBc & vbNullString
Else
  If Not ValidateRecArray(varRecBc) Then Err.Raise mconERR_BAD_REC_ARRAY, "GW::RecBc", "Invalid recipients array."
  intLBound = LBound(varRecBc, 2)
  For intCount = intLBound To UBound(varRecBc, 2)
    ReDim Preserve mastrRecBc(1, intCount - intLBound) 'make it 0-based
    mastrRecBc(0, intCount - intLBound) = CStr(varRecBc(0, intCount) & vbNullString)
    mastrRecBc(1, intCount - intLBound) = CStr(varRecBc(1, intCount) & vbNullString)
  Next intCount
End If

ExitHere:
  Exit Property

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere
 
End Property

Public Property Let RecCc(varRecCc As Variant)
'accepts an array of Cc: recipients: varRecCc(0, i)=address; varRecCc(1, i)=display name
'or a single address
On Error GoTo ErrHandler
Dim intCount As Integer
Dim intLBound As Integer

If Not IsArray(varRecCc) Then 'assume single address with no display name
  ReDim mastrRecCc(1, 0)
  mastrRecCc(0, 0) = varRecCc & vbNullString
Else
  If Not ValidateRecArray(varRecCc) Then Err.Raise mconERR_BAD_REC_ARRAY, "GW::RecCc", "Invalid recipients array."
  intLBound = LBound(varRecCc, 2)
  For intCount = intLBound To UBound(varRecCc, 2)
    ReDim Preserve mastrRecCc(1, intCount - intLBound) 'make it 0-based
    mastrRecCc(0, intCount - intLBound) = CStr(varRecCc(0, intCount) & vbNullString)
    mastrRecCc(1, intCount - intLBound) = CStr(varRecCc(1, intCount) & vbNullString)
  Next intCount
End If

ExitHere:
  Exit Property
 
ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere
 
End Property

Public Property Let RecTo(varRecTo As Variant)
'accepts an array of To: recipients: varRecTo(0, i)=address; varRecTo(1, i)=display name
'or a single address
On Error GoTo ErrHandler
Dim intCount As Integer
Dim intLBound As Integer

If Not IsArray(varRecTo) Then 'assume single address with no display name
  ReDim mastrRecTo(1, 0)
  mastrRecTo(0, 0) = varRecTo & vbNullString
Else
  If Not ValidateRecArray(varRecTo) Then Err.Raise mconERR_BAD_REC_ARRAY, "GW::RecTo", "Invalid recipients array."
  intLBound = LBound(varRecTo, 2)
  For intCount = intLBound To UBound(varRecTo, 2)
    ReDim Preserve mastrRecTo(1, intCount - intLBound) 'make it 0-based
    mastrRecTo(0, intCount - intLBound) = CStr(varRecTo(0, intCount) & vbNullString)
    mastrRecTo(1, intCount - intLBound) = CStr(varRecTo(1, intCount) & vbNullString)
  Next intCount
End If
 
ExitHere:
  Exit Property

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere
 
End Property

Public Sub RefreshAcct()
On Error GoTo ErrHandler

GW_Status "Refreshing account"

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::RefreshAcct", "Could not login to Groupwise."

mobjGWAcct.Refresh 'supposed to refresh all subordinates

ExitHere:
  GW_Status vbNullString
  Exit Sub

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Sub

Public Function SendMessage(strMessageID As String) As Boolean
'sends an existing draft message by MessageID
'need at least one To: recipient
'the draft message (strMessageID) goes to Trash if send successful,
'otherwise stays in the folder it was originally created (Work In Progress).
'the same message can be sent again, even if in Trash, unless
'.DeleteMessage( ,True) is used after the first send
On Error GoTo ErrHandler
Dim objMsg As Object
'Dim objMsg As GroupwareTypeLibrary.Message
Dim intCount As Integer
Dim blnError As Boolean, blnTo As Boolean

GW_Status "Sending message"

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::SendMessage", "Could not login to Groupwise."

On Error Resume Next
Set objMsg = mobjGWAcct.GetMessage(strMessageID)
On Error GoTo ErrHandler
If objMsg Is Nothing Then
  Err.Raise mconERR_COULD_NOT_SEND, "GW::SendMessage", "Could not get MessageID '" & strMessageID & "'."
  GoTo ExitHere
End If

If Not (objMsg.BoxType = egwDraft) Then Err.Raise mconERR_MSG_NOT_A_DRAFT, "GW::SendMessage", "MessageID '" & strMessageID & "' is not a draft message."

AddRecipients objMsg
 
If Not (objMsg.Recipients.Count > 0) Then
  Err.Raise mconERR_NO_RECIPIENTS, "GW::SendMessage", "Could not send message, no valid recipients defined for MessageID '" & strMessageID & "'."
  GoTo ExitHere
Else 'make sure there's at least one To recipient left after possible deletions
  For intCount = 1 To objMsg.Recipients.Count
    If objMsg.Recipients(intCount).TargetType = egwTo Then
      blnTo = True
      Exit For
    End If
  Next intCount
End If

If Not blnTo Then
  Err.Raise mconERR_NO_TO_RECIPIENTS, "GW::SendMessage", "Could not send message, no valid 'To:' recipients defined for MessageID '" & strMessageID & "'."
  GoTo ExitHere
End If

objMsg.Priority = mintPriority

objMsg.Send
SendMessage = True

ExitHere:
  On Error Resume Next
  Set objMsg = Nothing
  GW_Status vbNullString
  Exit Function

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Function

Public Property Let Subject(strSubject As String)
  mstrSubject = Left$(strSubject, 100)
End Property

Private Sub Class_Initialize()
On Error GoTo ErrHandler

#If Access Then
  mintErrTrapping = Application.GetOption("Error Trapping")
  Application.SetOption "Error Trapping", 2 'not effective in Class_Initialize
#End If

InitArrays
mintPriority = egwNormal

ExitHere:
  Exit Sub

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Sub


Private Sub Class_Terminate()
On Error Resume Next

Erase mastrRecTo, mastrRecBc, mastrRecBc, mastrFileAttachments, mastrNonResolved

Set mobjGWAcct = Nothing
mobjGWApp.Quit 'needed?
Set mobjGWApp = Nothing

#If Access Then
  Application.SetOption "Error Trapping", mintErrTrapping
#End If

GW_Status vbNullString

End Sub

Public Sub Login(Optional strLoginName As String, Optional strPassword As String)
On Error GoTo ErrHandler

GW_Status "Logging in to Groupwise"

Set mobjGWAcct = GWApp.Login(StrConv(strLoginName, vbUpperCase), , strPassword)

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::Login", "Could not login to Groupwise."

InitArrays

ExitHere:
  GW_Status vbNullString
  Exit Sub

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Sub
Public Function CreateMessage(Optional strFolder As String) As Variant
'creates a draft message (in specified folder if any) and returns GW MessageID on success
'if folder doesn't exist, will create it under root; if need it anyplace else, use .CreateFolder() beforehand
'recipients and priority cannot be saved with a draft message, have to add them immediately before send
On Error GoTo ErrHandler
Dim objMsg As Object
'Dim objMsg As GroupwareTypeLibrary.Message
Dim strTemp As String
Dim intCount As Integer

GW_Status "Creating draft message"

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::CreateMessage", "Could not login to Groupwise."

If Len(strFolder) > 0 Then 'make sure that the folder exists
  On Error Resume Next
  strTemp = mobjGWAcct.AllFolders.ItemByName(strFolder).Name
  Err.Clear
  On Error GoTo ErrHandler
  If Len(strTemp) > 0 Then 'it does
    Set objMsg = mobjGWAcct.AllFolders.ItemByName(strFolder).Messages.Add("GW.MESSAGE.MAIL", egwDraft)
  Else 'create folder
    Set objMsg = mobjGWAcct.AllFolders.Item(CStr(CreateFolder(strFolder))).Messages.Add("GW.MESSAGE.MAIL", egwDraft)
  End If
Else
  Set objMsg = mobjGWAcct.AllFolders.ItemByName(mconDefaultFolder).Messages.Add("GW.MESSAGE.MAIL", egwDraft)
End If
If objMsg Is Nothing Then GoTo ExitHere

If Len(mstrSubject) > 0 Then
  objMsg.Subject = mstrSubject
Else
  objMsg.Subject = Space(1) 'otherwise GW will use first 100 chars of msg body
End If
If Len(mstrBodyText) > 0 Then objMsg.BodyText = mstrBodyText
If Len(mstrFromText) > 0 Then objMsg.FromText = mstrFromText
For intCount = 0 To UBound(mastrFileAttachments)
  If Len(mastrFileAttachments(intCount)) > 0 Then
    objMsg.Attachments.Add mastrFileAttachments(intCount), egwFile
  End If
Next intCount
objMsg.Refresh
CreateMessage = objMsg.MessageID

ExitHere:
  On Error Resume Next
  Set objMsg = Nothing
  GW_Status vbNullString
  Exit Function
 
ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere
 
End Function


Public Property Get AvailableProxies(Optional blnRefresh As Boolean) As Variant
'slow
'may show 'access denied' errors on POA console with C/S access
On Error GoTo ErrHandler
Static varProxies As Variant
Dim objAccount As Object
Dim objAddrBookEntry As Object
'Dim objAccount As GroupwareTypeLibrary.Account
'Dim objAddrBookEntry As GroupwareTypeLibrary.AddressBookEntry

GW_Status "Getting Proxies"

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::AvailableProxies", "Could not login to Groupwise."

If IsEmpty(varProxies) Or blnRefresh Then 'do it once, then cache the array
  For Each objAddrBookEntry In mobjGWAcct.AddressBooks(mconSystemAddrBookName).AddressBookEntries
    'attempt to proxy to each address in the system addr. book
    'otherwise the ProxyAccounts collection is empty
    If objAddrBookEntry.ObjType = egwUser Or objAddrBookEntry.ObjType = egwResource Then
      On Error Resume Next
      GWApp.Proxy objAddrBookEntry.EmailAddress
      On Error GoTo ErrHandler
    End If
  Next objAddrBookEntry
 
  'get proxy addresses
  ReDim varProxies(0)
  For Each objAccount In GWApp.ProxyAccounts
    varProxies(UBound(varProxies)) = objAccount.Owner
    ReDim Preserve varProxies(UBound(varProxies) + 1)
  Next objAccount
 
  If Len(varProxies(0) & vbNullString) > 0 Then
    ReDim Preserve varProxies(UBound(varProxies) - 1)
  Else
    varProxies = Null
  End If
End If

AvailableProxies = varProxies

ExitHere:
  GW_Status vbNullString
  Exit Property

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Property

Public Sub Proxy(strAddress As String)
On Error GoTo ErrHandler
Static objGWAcct As Object
'Static objGWAcct As GroupwareTypeLibrary.Account

GW_Status "Proxying"

If mobjGWAcct Is Nothing Then Err.Raise mconERR_LOGIN_UNSUCCESSFUL, "GW::Proxy", "Could not login to Groupwise."

Set objGWAcct = Nothing
On Error Resume Next
Set objGWAcct = GWApp.Proxy(strAddress)
On Error GoTo ErrHandler

If objGWAcct Is Nothing Then
  Err.Raise mconERR_COULD_NOT_PROXY, "GW::Proxy", "Could not proxy to specified address."
Else
  Set mobjGWAcct = objGWAcct
End If

ExitHere:
  GW_Status vbNullString
  Exit Sub

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Sub

Public Property Get IsAcctProxied() As Boolean
On Error GoTo ErrHandler

IsAcctProxied = mobjGWAcct.Proxied

ExitHere:
  Exit Property

ErrHandler:
  Err.Raise Err.Number, Err.Source, Err.Description
  Resume ExitHere

End Property

'****End of Code******


Good Luck!
Cheers
M
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
Emanon_Consulting,

Thats what we are trying to play with

ShaneDavidson:

Im stupmed!.. Got you as far as putting it in the WIP, but thats all i can sus out at the moment..
0
 
LVL 1

Author Comment

by:ShaneDavidson
Comment Utility
flavo,

If you can save message into WIP then loop through to get the last message in WIP can you get the message id? then use the code?:

Set vCommander = CreateObject("GroupWiseCommander")
ParamStr = "ItemOpen(""" + MyMsgID + """)"
iRet = vCommander.Execute(ParamStr, sResult)

(your code from developer.novell.com/research/ebooks/GWDevGuide.pdf
)
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
I tired to do that, and could get it out...  Ill look again...
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
Go it!!!!!

woooo!!!!

Sub openEmail()

Dim oApp As Object
Dim oAcct As Object
Dim oFolders As Folders
Dim oFolder As Folder
Dim oMessages As Messages
Dim oMessage As Message
Dim oAttach As Attachment
Dim MyMsgID As Variant
Dim vCommander As Object
Dim ParamStr As String
Dim iRet As Integer
Dim sResult As String


'open connection to GW
Set oApp = CreateObject("NovellGroupWareSession")
Set oAcct = oApp.Login("", "")


Set oFolders = oAcct.AllFolders

'loop over folders until we get the BLISSPrint area
For Each oFolder In oFolders

    If oFolder.Name = "Work In Progress" Then
        Set oMessages = oFolder.Messages
        'loop over all the msg's in there
        For Each oMessage In oMessages
             Debug.Print oMessage.CreationDate
             
           '  Open the new message to view it
MyMsgID = oMessage.MessageID
Debug.Print oMessage.MessageID

Set vCommander = CreateObject("GroupWiseCommander")
ParamStr = "ItemOpen(""" + MyMsgID + """)"
iRet = vCommander.Execute(ParamStr, sResult)

             
             
        Next
       
     End If
Next




'clean up
Set oApp = Nothing
Set oAcct = Nothing
Set oFolders = Nothing
Set oFolder = Nothing
Set oMessages = Nothing
Set oMessage = Nothing
Set oAttach = Nothing



End Sub
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
Ill just clean her up a little
0
 
LVL 34

Accepted Solution

by:
flavo earned 500 total points
Comment Utility
Here's all the code

Addds C:\1.txt and c:\2.txt to the email
Subject - Subj
Body - body2

Addresses are waiting for you to add

Enjoy!

Sub RunDemo()
'this is a sample usage routine
On Error GoTo Err_Handler
Dim strTemp As String
Dim varAttach(1) As Variant
Dim lngCount As Long
Dim varProxies As Variant
Dim cGW As GW

varAttach(0) = "c:\1.txt"
varAttach(1) = "c:\2.txt"



Set cGW = New GW
With cGW
  .Login
  .BodyText = "body2"
  .Subject = "subj"
  .FileAttachments = varAttach
  .Priority = "High"
  strTemp = .CreateMessage
  .ResolveRecipients strTemp
  If IsArray(.NonResolved) Then MsgBox "Some unresolved recipients."
End With

Exit_Here:
  Set cGW = Nothing
  Call openEmail
  Exit Sub

Err_Handler:
  MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical
  Resume Exit_Here

End Sub

Sub openEmail()

Dim oApp As Object
Dim oAcct As Object
Dim oFolders As Folders
Dim oFolder As Folder
Dim oMessages As Messages
Dim oMessage As Message
Dim oAttach As Attachment
Dim MyMsgID As Variant
Dim vCommander As Object
Dim ParamStr As String
Dim iRet As Integer
Dim sResult As String
Dim dtMsg As Date

'open connection to GW
Set oApp = CreateObject("NovellGroupWareSession")
Set oAcct = oApp.Login("", "")
Set oFolders = oAcct.AllFolders
dtMsg = 0
'loop over folders until we get the WIP
For Each oFolder In oFolders

    If oFolder.Name = "Work In Progress" Then
        Set oMessages = oFolder.Messages
        'loop over all the msg's in there
        For Each oMessage In oMessages
             If oMessage.CreationDate > dtMsg Then
                dtMsg = oMessage.CreationDate
                MyMsgID = oMessage.MessageID
             End If
        Next
             'Open the new message to view it
             Set vCommander = CreateObject("GroupWiseCommander")
             ParamStr = "ItemOpen(""" + MyMsgID + """)"
             iRet = vCommander.Execute(ParamStr, sResult)
     End If
Next




'clean up
Set oApp = Nothing
Set oAcct = Nothing
Set oFolders = Nothing
Set oFolder = Nothing
Set oMessages = Nothing
Set oMessage = Nothing
Set oAttach = Nothing
Set vCommander = Nothing


End Sub
0
 
LVL 1

Author Comment

by:ShaneDavidson
Comment Utility
Thanks, that's spot on.

Points well deserved.
0
 
LVL 34

Expert Comment

by:flavo
Comment Utility
Im just happy i got it out
0
 
LVL 7

Expert Comment

by:UniqueData
Comment Utility
Shane, are you still out there?

I am wanting to do the same thing and tried to code flavo posted.  I am getting the same issue you were having, the email is getting sent to my InBox, not WIP folder.  How did you resolve that part?
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now