?
Solved

E-mail a word form with subject & cc

Posted on 2001-06-20
7
Medium Priority
?
885 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
Independent Software Vendors: 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 200 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

777 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