/ Forums / Advansys Formativ / Creating Solutions with Formativ / Create Fax form and attachments

  • Creator
  • #4063

      We have just recently installed a new fax server into our GW system. What we need to do is force all messages that are addressed to “FAX:<number>” to have a cost centre entered into the body of the message for costing/billing purposes. We have 2 possible ways to perform this.

      The first option is to create a form which asks users to enter the fax number, cost centre, subject, body of email and any attachments. I have managed to do this with the exception of allowing files to be attached. It then maps the info entered into these fileds to the appropriate mail fields and then sends it. The problem here is being able to attach files from the file system and from our Document Management System. Is there anyway to do this? Even if we click a next button and it gives them the attach documents dialog. The code I am using to do this is below.

      The second option is to have an applet that runs on Send which checks to see if the To: address contains FAX: and then displays a dialog box asking the user to enter a cost centre and then appends this to the body of the email.

      Is either of the ideas feasible?

      Here is the code for the first option.

      ‘Wizard dialogs and controls
      dim IntroDlg

      ‘Other variables
      dim Cmd
      dim FSO
      dim Msg
      dim HRT
      dim MsgID
      dim FaxCtl
      dim SubCtl
      dim MatterCtl
      Dim objMail
      Dim objNewMail
      Dim objRecipient
      dim BodyCtl

      CAPTION = “Send Fax”

      Const cExit = 999

      ‘ Main Function

      Sub Main(Client, GWEvent)

      HRT = Chr(13) & Chr(10)
      ‘ Create Group wise address book object
      set FSO = CreateObject(“Scripting.FileSystemObject”)

      ‘ Dialogs
      ‘ Command button
      cDoIntro = 100
      cCreateFax = 103
      cEndDlg = 109

      Cmd = cDoIntro

      Do While Cmd <> cExit

      ‘Display Introduction dialog
      if Cmd = cDoIntro then
      select case IntroDlg.execute
      case Btn1 Cmd = cCreateFax
      case Btn2 Cmd = cExit
      end select
      end if

      ‘ Create reminder email
      if Cmd = cCreateReminderEmail then
      Cmd = cExit
      end if

      set FSO = nothing

      End Sub

      ‘ Create reminder email
      function CreateReminder

      dim iMsgObject

      Set objMail = GroupWise.Account.MailBox.Messages.Add(“GW.MESSAGE.MAIL”)
      Set objRecipient = objMail.Recipients.Add(“FAX:” & FaxCtl.Text,,0)
      With objMail
      ‘.Priority = Priority
      ‘.FromText = “Automated Reminder Email”
      .Subject = SubCtl.Text
      if BodyCtl.Text <> “” then
      .BodyText.PlainText = “++COST ” & MatterCtl.Text & HRT & HRT & BodyCtl.Text
      end if
      ‘.DelayedDeliveryDate = DateCtl.Date & ” ” & TimeCtl.Time

      End With
      Set objNewMail = objMail.Send
      Set objRecipient = Nothing
      Set objMail = Nothing

      end function

      ‘ Introduction dialog

      Function SetupIntroDlg(Client)

      set IntroDlg = Utilities.NewControlBoxDialog
      with IntroDlg
      .AutoSize = TRUE
      .Caption = CAPTION
      .Title = “Send Fax”
      .Button1Caption = “&OK”
      .Button2Caption = “&Cancel”
      .WizardImage = WIZARDIMAGE
      end with

      Set FaxCtl = IntroDlg.AddEditControl
      with FaxCtl
      .Caption = “Fax Number:”
      .Hint = “Enter the Fax Number to send to”
      .Width = 100
      end with

      set MatterCtl = IntroDlg.AddEditControl
      with MatterCtl
      .Caption = “Matter number:”
      .Width = 100
      .Hint = “Enter the Matter number this should be billed to”
      end with

      set SubCtl = IntroDlg.AddEditControl
      with SubCtl
      .Caption = HRT & “Use this subject for the fax:”
      .MaxLength = 100
      .Hint = “Enter a subject for the fax”
      end with

      set BodyCtl = IntroDlg.AddmemoControl
      with BodyCtl
      .Caption = “Enter the Body of the fax here”
      .Height = 50
      .Scrollbars = 4
      .Wordwrap = TRUE
      end with

      End Function

    • Author
    • #6995
      Support 1a

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

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