Question : Attachments to GroupWise

The following code will accept one attachment to a GroupWise message.  Everything works great.  The problem is that my boss would like to be able to send more than one attachment.  I have tried various combinations and can't get it to recognize a second attachment.  The Expert that helped me the first time is busy and suggested that i submit the question to the group. Anyone have a clue?

Private Sub Send_Click()

On Error GoTo Err_Send_Click
   DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim dbs As Database, rst As Recordset
Dim dbsf As Database, rstf As Recordset
'Second attachment
Dim dbsf_2 As Database, rstf_2 As Recordset

Dim objGroupWise As Object, objAccount As Object, objMailbox As Object
Dim objMessage As Object, objMessages As Object, objRecipients As Object
Dim objRecipient As Object, MessageSent As Variant
Dim objAttachments As Object, objFile As Object
'Second attachment
Dim objAttachments_2 As Object, objFile_2 As Object

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tbl_1")
   rst.MoveFirst
   Do Until rst.EOF
Set objGroupWise = CreateObject("NovellGroupWareSession")
Set objAccount = objGroupWise.Login
Set objMailbox = objAccount.Mailbox
Set objMessages = objMailbox.Messages
Set objMessage = objMessages.Add("GW.MESSAGE.MAIL", "egwDraft")
Set objRecipients = objMessage.Recipients
Set objAttachments = objMessage.Attachments

Set objRecipient = objRecipients.Add(rst![e_mail])
' Trap for no attachment
   If IsNull(filename.Value) Then
Set dbsf = CurrentDb()
Set rstf = dbsf.OpenRecordset("tbl_message")
   Me.email = objRecipient
objMessage.Subject = Me.Title
objMessage.BodyText = Me.Message
objMessage.Send
MsgBox ("Message Sent!")
   rst.MoveNext
   Else
' Attach a file
Set dbsf = CurrentDb()
Set rstf = dbsf.OpenRecordset("tbl_message")
Set objAttachments = objAttachments.Add(rstf![filename])
   
   Me.email = objRecipient
objMessage.Subject = Me.Title
objMessage.BodyText = Me.Message
objMessage.Send
MsgBox ("Message Sent!")
   rst.MoveNext
   End If
   Loop
   
Exit_Send_Click:
   Exit Sub
Err_Send_Click:
   MsgBox Err.Description
   Resume Exit_Send_Click
End Sub

Answer : Attachments to GroupWise

Sorry it took so long to get back to you - if you are still working on the problem you will need to reference the GroupWare type library that should be available to you if you are using the GroupWise (I found that the other libraries that were available were not necessary).  Novell also has a site with alot of info http://developer.novell.com/ndk/doc/gwobjapi/index.html?gwobjenu/data/h7ikbsqg.html
Random Solutions  
 
programming4us programming4us