Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Aug 2003
    Location
    Lake Forest, Illinois, USA
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Email button in word (2003)

    Hi there! I am trying to include a button on an MS word document that I am creating which automatically launches outlook with my email address, subject line (title of my form) and the form included in the body of the email. Can this be done in word? I know that there is a 'Mail recipient' option in the File menu, but I want the users to complete the form and simply click the button on the bottom and have my email address, subject and form already auto populated for them. Your help is very much appreciated! <img src=/S/smile.gif border=0 alt=smile width=15 height=15> <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Email button in word (2003)

    <P ID="edit" class=small>(Edited by jscher2000 on 10-Sep-08 21:13. )</P>I think the tricky part is getting a filled-in form into the message body without losing the form values or embedding contents that raises security alarms. It might be easier to actually put field=value pairs into the message. Here's a sample macro to read a table that contains text and form fields and insert it into a new Outlook message:

    <code>Sub MakeMessage()
    'Generate new message
    Dim olApp As Outlook.Application, olNS As Outlook.NameSpace
    Dim olNewMsg As Outlook.MailItem
    'Set object reference to Outlook and, if nec. start it/logon
    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")
    If Err.Number = 429 Then 'Outlook was not open...
    Err.Clear
    On Error GoTo 0
    Set olApp = CreateObject("Outlook.Application")
    Set olNS = olApp.GetNamespace("MAPI")
    olNS.Logon
    Else
    On Error GoTo 0
    Set olNS = olApp.GetNamespace("MAPI")
    End If
    'Create and populate new message
    Set olNewMsg = olApp.CreateItem(olMailItem)
    With olNewMsg
    Dim recip As Recipient
    Set recip = .Recipients.Add("John Doe")
    recip.Type = olTo
    Set recip = .Recipients.Add("Jane Roe")
    recip.Type = olCC
    .Subject = "Check Request/Needed: " & ActiveDocument.FormFields("ReqdDate").Result
    .Body = "Hello, please process this Check Request at your earliest " & _
    "convenience. If you have any questions, please let me know." & _
    vbCrLf & vbCrLf
    Dim intRows As Integer, intRowCounter As Integer
    Dim tbl As Table, strText As String, frmFld As FormField
    Set tbl = ActiveDocument.Tables(1)
    intRows = tbl.Rows.Count
    For intRowCounter = 1 To intRows
    If tbl.Rows(intRowCounter).Cells.Count > 1 Then
    If tbl.Cell(intRowCounter, 2).Range.FormFields.Count = 0 Then
    'this is meant to be copied over as text
    .Body = .Body & "<Row " & intRowCounter & " blank>" & vbCrLf
    Else
    'tack on the non-empty form field values, separated by VbCrLf
    For Each frmFld In tbl.Cell(intRowCounter, 2).Range.FormFields
    If Len(frmFld.Result) > 0 Then
    .Body = .Body & frmFld.StatusText & " " & frmFld.Result & vbCrLf
    End If
    Next
    End If
    End If
    Next
    .Display
    .Recipients.ResolveAll
    End With
    If Not frmFld Is Nothing Then Set frmFld = Nothing
    If Not tbl Is Nothing Then Set tbl = Nothing
    If Not recip Is Nothing Then Set recip = Nothing
    If Not olNewMsg Is Nothing Then Set olNewMsg = Nothing
    If Not olNS Is Nothing Then Set olNS = Nothing
    If Not olApp Is Nothing Then Set olApp = Nothing
    End Sub</code>

    Added: I used a MACROBUTTON field in my form, but that requires a double-click. I think the ActiveX button only requires a single click.

  3. #3
    Lounger
    Join Date
    Aug 2003
    Location
    Lake Forest, Illinois, USA
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email button in word (2003)

    Ha ha! Yes, I think I did set the record for duplicate postings!!! LOL!

    Thanks VERY much for your reply, it worked great!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •