/ Forums / Advansys Formativ / Creating Solutions with Formativ / How to clone a received message

  • Creator
    Topic
  • #4170
    Immi
    Participant

      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

    • Author
      Replies
    • #7347
      MA
      Participant

        Cloning a received message is not allowed. You can only clone personal or draft message. Hope this helps.

        MA

        #7354
        Support 1a
        Participant

          Even though it’s not documented by Novell, I think this is correct. (possibly for reasons of security).

          Advansys Support

          #7353
          Immi
          Participant

            In 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

            #7352
            MA
            Participant

              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

              #7351
              Support 1a
              Participant

                Thanks MA.

                Advansys Support

                #7350
                Immi
                Participant

                  Hi!

                  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
                  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)

                  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

                  #7349
                  MA
                  Participant

                    quote:


                    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
                    MA

                    #7355
                    Support 1a
                    Participant

                      Thanks 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

                      #7356
                      Immi
                      Participant

                        Hi

                        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!
                        Stephan

                        #7348
                        Support 1a
                        Participant

                          Great news! Thank everyone for your input.

                          Advansys Support

                        Viewing 10 replies - 1 through 10 (of 10 total)
                        • You must be logged in to reply to this topic.