/ Forums / Advansys Formativ / Creating Solutions with Formativ / How to clone a received message
-
CreatorTopic
-
October 18, 2005 at 11:21 pm #4170
Hi
Could you please post a few lines of source code on how to clone a received message? I have found some code on cloing posted appointments, but I could not figure out how to adapt it for received messages.
TIA Stephan
-
CreatorTopic
-
AuthorReplies
-
October 19, 2005 at 3:49 pm #7347
Cloning a received message is not allowed. You can only clone personal or draft message. Hope this helps.
MA
October 20, 2005 at 4:46 pm #7354Even though it’s not documented by Novell, I think this is correct. (possibly for reasons of security).
Advansys Support
October 21, 2005 at 3:03 am #7353In another post I have read that the ‘Delete Attachments from Selected Messages’ addin is using cloning. How is it done there?
I would like to write addin which combines the functions of the ‘Delete Attachments from Selected Messages’ addin with the ‘space saver’.
Ideally the properties of the original message should remain untouched (as with ‘Delete Attachments from Selected Messages’, and the original message should be updated with references to the file locations of the saved/removed messages.
Stephan
October 22, 2005 at 11:56 am #7352Delete 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 oRecipientset 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
nextset 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 = nothingEnd Sub
‘ Move message to a folder
private sub MoveMessages(aMsg, aFolder)dim oEnclosingFolders
dim oParentFolderOn 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 ifset oEnclosingFolders = nothing
end subThanks
MAOctober 23, 2005 at 4:22 pm #7351Thanks MA.
Advansys Support
October 24, 2005 at 2:25 am #7350Hi!
Thanks for you hints! So far I have managed to create a new message with the listet source code.
However I cann talter the contents of the original message. Here is my code:‘ 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 & vbCrLf & “Attached files saved to:” & vbCrLf & AttachFileName
oDraftMsg.BodyText.RTF = oMsg.BodyText.RTF & vbCrLf & “Attached files saved to:” & vbCrLf & AttachFileName‘ Setup the recipients
for x = 1 to oMsg.Recipients.count
set oRecipient = oMsg.Recipients.item(x)
call oDraftMsg.Recipients.Add(oRecipient.EmailAddress,,oRecipient.TargetType)
set oRecipient = nothing
nextset oNewMsg = oFolder.Messages.AddExistingMessage(oMsg.Sender.DisplayName, oMsg.Sender.EmailAddress, oMsg.Sender.EmailType, oMsg.CreationDate, oMsg.BoxType, 1, oMsg.Priority, 0, oDraftMsg, oMsg.ModifiedDate)
What ever I try the message text remains unchanged. Secondly the resulting message is only plain text (no more HTML).
What am I doing wrong?
Stephan
October 24, 2005 at 4:17 pm #7349quote:
Originally posted by Immi:
What ever I try the message text remains unchanged.
The rich text format (RTF) is not valid. In RTF hard return should be replace by par, check RTF Specification for more details.
quote:
Originally posted by Immi:
resulting message is only plain text (no more HTML)
I order to create html message in GroupWise you have to supplied TEXT.htm as an attachment to the new message.
Thanks
MAOctober 25, 2005 at 4:15 pm #7355Thanks MA. Depending on the situation, simply supplying a TEXT.htm attachment may not be enough, and creation of a MIME.822 attachment may be required.
Advansys Support
October 27, 2005 at 6:45 am #7356Hi
I have decided to forget about the HTML / RTF part in the message. Therefore MA’s source code works just fine (I just REMed out “oDraftMsg.BodyText.RTF = oMsg.BodyText.RTF & vbCrLf & “Attached files saved to:” & vbCrLf & AttachFileName”).
Thanks for all your input!
StephanOctober 27, 2005 at 4:31 pm #7348Great news! Thank everyone for your input.
Advansys Support
-
AuthorReplies
- You must be logged in to reply to this topic.