#6432
Support 1a
Participant

There are a couple of ways to do this. Here are two examples:

Example 1:
This example using native Object API calls. Notice that we do a forward in order to build a new message with the original attached. We then fill out the appropriate information in the new draft forward. We have found this is the most reliable way to attach a message object to a new message.

'-------------------------------------------------------------------------------
' Create a message and attach the selected message through using the Object API
'-------------------------------------------------------------------------------

Sub Main(Client, GWEvent)

Dim objDraft
Dim objEmail
Dim objRecipient
Dim Archief

' Voeg parameters toe
On Error Resume Next
Set Msg = Client.ClientState.CommandMessage

set objDraft = Msg.Forward

with objDraft
call .Recipients.Add(GroupWise.Account.Owner.EmailAddress, ,0)
.Subject = "Test"
.BodyText = "Body text"
end with

' Verstuur het bericht dmv de verzend methode
Set objEmail = objDraft.Send

' Verzend bevestiging
Call MsgBox("Dank U.", 64, "Bericht verzonden.")

End Sub

Example 2:

'-------------------------------------------------------------------------------
' Create a new message and attach the selected message using token commands.
'-------------------------------------------------------------------------------
Sub Main(Client, GWEvent)

' Check to see whether we have selected any messages
On Error Resume Next
Set Msg = Client.ClientState.CommandMessage
if isobject(Msg) then
MsgID = Msg.MessageID
end if

Archief = GroupWise.Account.Owner.EmailAddress

'Create a new Mail
GroupWise.NewMail
Set NewMsg = GroupWise.ComposingItem
with NewMsg
.To_ = Archief
.Subject = "Archivering gewenst"
.BodyText = "Graag dit bericht archiveren."
end with

' Attached the selected message
if MsgID <> "" then
call GroupWise.ItemAttachmentAdd("X00", itcAttachClassMessage, Msg.MessageID, "")
end if

GroupWise.ItemSend(0)

set Msg = nothing
set NewMsg = nothing

End Sub

You will notice that we check for the existence of a return value from Client.ClientState.CommandMessage
using a combination of both On Error Resume Next and the IsObject() function.

I hope this information helps.

Advansys Support