Solved

E-mail a word form with subject & cc

Posted on 2001-06-20
7
878 Views
Last Modified: 2011-10-03
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
0
Comment
Question by:thocutt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 3

Expert Comment

by:Maxim10553
ID: 6212600
0
 
LVL 2

Expert Comment

by:Microsoft
ID: 6213059
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
0
 

Author Comment

by:thocutt
ID: 6215791
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?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
levr earned 50 total points
ID: 6220283
' create a session object and open session
    Set oSess = GetObject(, "mapi.Session")
    If oSess Is Nothing Then Set oSess = GetObject("", "mapi.Session")
    oSess.Logon profileName:="email_userid"

' then you can manipulate with the message before sending
Set oMess = oSess.Outbox.Messages.Add
        Set oRec = oMess.Recipients.Add
        oRec.Name ="email_address"
        oRec.Resolve
        oMess.Subject ="subject"
        oMess.Text = strTemp
        oMess.DeliveryReceipt = False
        oMess.Update
        oMess.Send SaveCopy:=False, ShowDialog:=False

Good Luck,
Lev
0
 

Author Comment

by:thocutt
ID: 6228272
Hmmm, let me try this out.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7139621
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
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7181626
Per recommendation, force-accepted.

Netminder
CS Moderator

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question