/ Forums / Advansys Formativ / Creating Solutions with Formativ / How to clone a received message / Reply To: How to clone a received message
Delete Attachments from Selected Messages solution use AddExistingMessage method of Message objects. See the GroupWise Object API documentation for more details. This method is available only in GroupWise 6.0, SP1 and later versions. The sample code below use the AddExistingMessage method to create a new message based on the selected message. You can update the new message properties (bodytext, attachments, etc) with references to the file locations of the saved or removed messages.
‘——————————————————————————-
‘ Mainline processing
‘——————————————————————————-
Sub Main(Client, GWEvent)
dim x
dim oMsg
dim oFolder
dim oDraftMsg
dim oNewMsg
dim oRecipient
set oMsg = client.clientstate.commandmessage
set oFolder = Client.ClientState.SelectedFolder
‘ Create a draft message and set the subject and body text
Set oDraftMsg = oFolder.Messages.Add(fgwDraft)
oDraftMsg.subject.plaintext = oMsg.subject.plaintext
oDraftMsg.BodyText.PlainText = oMsg.BodyText.PlainText
oDraftMsg.BodyText.RTF = oMsg.BodyText.RTF
‘ Setup the recipients
for x = 1 to oMsg.Recipients.count
set oRecipient = aMsg.Recipients.item(x)
call oDraftMsg.Recipients.Add(oRecipient.EmailAddress,,oRecipient.TargetType)
set oRecipient = nothing
next
set oNewMsg = oFolder.Messages.AddExistingMessage(oMsg.Sender.DisplayName, oMsg.Sender.EmailAddress, oMsg.Sender.EmailType, oMsg.CreationDate, oMsg.BoxType, 1, oMsg.Priority, 0, oDraftMsg, oMsg.ModifiedDate)
‘ Move the message to the selected folder if the messages enclosing folder
‘ is not the selected folder
call MoveMessages(oNewMsg, oFolder)
set oDraftMsg = nothing
set oMsg = nothing
set oFolder = nothing
set oNewMsg = nothing
End Sub
‘ Move message to a folder
private sub MoveMessages(aMsg, aFolder)
dim oEnclosingFolders
dim oParentFolder
On Error Resume Next
set oEnclosingFolders = aMsg.EnclosingFolders
if isobject(oEnclosingFolders) then
if (oEnclosingFolders.count > 0) then
set oParentFolder = oEnclosingFolders.item(1)
if isobject(oParentFolder) then
if (oParentFolder.FolderID <> aFolder.FolderID) then
call oParentFolder.Messages.Move(aMsg, aFolder.messages)
end if
end if
set oParentFolder = nothing
end if
end if
set oEnclosingFolders = nothing
end sub
Thanks
MA