Solved

E-mail a word form with subject & cc

Posted on 2001-06-20
7
867 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
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now