Link to home
Start Free TrialLog in
Avatar of thocutt
thocutt

asked on

E-mail a word form with subject & cc

I have a Microsoft Word form in a template and I created a button so they can submit the form via e-mail when they are done filling it out, but I'm not sure how to automatically populate the CC: Field and the Subject: Field of the e-mail.

I'm using this code which opens up an e-mail message with the document as an attachment.  How can I add text for the CC's and the subject?:

Private Sub CommandButton1_Click()
Options.SendMailAttach = True
ActiveDocument.SendMail
End Sub
Avatar of Maxim10553
Maxim10553
Flag of United States of America image

Avatar of Microsoft
Microsoft

nare dont bother with that link

try this matey

this will show how to user the other fields you want to complete

Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile As String, ByVal lpParameters _
As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Private Const SW_SHOW = 5

Public Function OpenEmail(ByVal EmailAddress As String, _
    Optional Subject As String, Optional Body As String) _
    As Boolean

    Dim lWindow As Long
    Dim lRet As Long
    Dim sParams As String
   
    sParams = EmailAddress
    If LCase(Left(sParams, 7)) <> "mailto:" Then _
        sParams = "mailto:" & sParams
 
 If Subject <> "" Then sParams = sParams & "?subject=" & Subject
       
    If Body <> "" Then
        sParams = sParams & IIf(Subject = "", "?", "&")
        sParams = sParams & "body=" & Body
    End If

   lRet = ShellExecute(lWindow, "open", sParams, _
    vbNullString, vbNullString, SW_SHOW)
   
   OpenEmail = lRet = 0

End Function

cheers

Andy
Avatar of thocutt

ASKER

Isn't there an easier way to do this like

Private Sub CommandButton1_Click()
Options.SendMailAttach = True
ActiveDocument.SendMail(,"thocutt@yahoo.com","Travel Arrangements", , )
End Sub

I always want the subject and CC to be the same.  Does is have to be a boatload of code, or can it be simple like above?
ASKER CERTIFIED SOLUTION
Avatar of levr
levr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thocutt

ASKER

Hmmm, let me try this out.
Avatar of DanRollins
Hi thocutt,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Split points between: Maxim10553 and levr@devx

thocutt, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.

Netminder
CS Moderator

Maxim10553: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20328654