#6995
Support 1a
Participant

    Thank you for your questions above. Yes, both the approaches mentioned are technically feasible.

    I’ve included some sample code below to help illustrate a couple of points. Firstly, you’ll find some code showing how to attach an existing message to a draft email message. This could possibly be modified to attach a document reference (which is just a message sub-type) to a message. Secondly, the code also shows how to attach a file to a composing message:

    ' Create and send a message to the current user.
    sub AttachMessage(aID)
     
      dim oGWMessage
      dim oNewMessage
     
      on error resume next
     
      if (len(aID) = 0) then
        exit sub
      end if
     
      set oGWMessage = GroupWise.Account.GetMessage(aID)
      if oGWMessage is nothing then
        msgbox "No existing GroupWise message found to attach"
        exit sub
      end if
     
      ' Note: Adding existing messages as an attachment was previously broken. Novell fixed this in
      ' GroupWise 6.5.2.
      if (GroupWise.EnvVersionName >= "6.5.2") then
        Set oNewMessage = GroupWise.Account.workfolder.Messages.Add("GW.MESSAGE.MAIL")
        call oNewMessage.Attachments.Add(oGWMessage, "")
      else
        set oNewMessage = oGWMessage.Forward
      end if
     
    
      call oNewMessage.Recipients.Add(GroupWise.Account.owner.emailaddress,,0)
      With oNewMessage
        .Subject = "With message attachment"
        .BodyText.PlainText = "This is the body"
      End With
     
      oNewMessage.Send
     
      set oNewMessage = nothing
      set oGWMessage = nothing
     
    end sub
      
     
    ' Create and send a message to the current user. Attach a file from the file system.
    sub AttachFile()
     
      dim oFileDlg
      dim oGWMessage
     
      ' Initialize the file open dialog
      set oFileDlg = Utilities.NewOpenFileDialog
      with oFileDlg
        .Title = "File to attach"
        .InitialDir = Utilities.GetDataDirectory
        .DefaultExt = "*.txt"
        .Filter = "Text file(*.txt)|*.TXT"
      end with
     
      ' Exit if the user press cancel from the file open dialog
      if not oFileDlg.execute then
        msgbox "No file selected to attached."
        exit sub
      end if
     
      ' Create a mail message and set the recipient to the login user.
      Set oGWMessage = GroupWise.Account.workfolder.Messages.Add("GW.MESSAGE.MAIL")
      call oGWMessage.Recipients.Add(GroupWise.Account.owner.emailaddress,,0)
     
      With oGWMessage
        .Subject = "With file attachment"
        .BodyText.PlainText = "This is the body"
      End With
     
      ' Attach the file
      call oGWMessage.Attachments.Add(oFileDlg.FileName, fgwFile, "")
      oGWMessage.Send
     
      msgbox ("Message sent with the following attachment: " & vbcrlf & oFileDlg.FileName)
     
      set oGWMessage = nothing
      set oFileDlg = nothing
     
    end sub
    

    I would probably recommend the second option – check the subject on send and prompt for input. (but there may be other factors I am unware of they make option 1 the more appropriate approach).

    I hope this helps.

    Advansys Support