Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendMail Help

Status
Not open for further replies.

pd84313

Programmer
Aug 26, 2002
11
AU
Does the sendmail command in word's vba have a recipient option ? or does it just open up a new email with the document as either the body text or as an attachment ?

works in excel : |

 
From Xl help file (assuming you want xl ... ;-))
Code:
Sends the workbook by using the installed mail system.

Syntax

expression.SendMail(Recipients, Subject, ReturnReceipt)

expression   Required. An expression that returns a Workbook object.

Recipients   Required Variant. Specifies the name of the recipient as text, or as an array of text strings if there are multiple recipients. At least one recipient must be specified, and all recipients are added as To recipients.

Subject   Optional Variant. Specifies the subject of the message. If this argument is omitted, the document name is used.

ReturnReceipt   Optional Variant. True to request a return receipt. False to not request a return receipt. The default value is False.

Remarks

Use the SendMail method in Microsoft Mail (MAPI or Microsoft Mail for the Macintosh) e-mail systems. Pass addressing information as parameters.

Use the SendMailer method in PowerTalk e-mail systems on the Macintosh. The Mailer object contains the addressing information for PowerTalk.

HTH

Cheers
Nikki
 
In Word:
Code:
Opens a message window for sending the specified document through Microsoft Exchange. 

Note   Use the SendMailAttach property to control whether the document is sent as text in the message window or as an attachment. 

Syntax

expression.SendMail

expression   Required. An expression that returns a Document object.
And no, there's no RECIPIENT property that you can set

Dunno why

Will take a further look, but I think it's probab;ly a question of using the MAPI object yourself

Cheers
Nikki ;-)
 
Thanks - I was going to use mapi but I saw the sendmail command and thought it would work - nice of Microsofts development teams to talk to each other - the excel team must get paid more ?
 
Or are smarter ;-)

Dug a little deeper & found this:
Code:
Sub TestSendMail()
    Dim l_docDocument As Word.Document
    
    Set l_docDocument = ThisDocument
    
    l_docDocument.HasRoutingSlip
    l_docDocument.RoutingSlip.Subject
    l_docDocument.RoutingSlip.AddRecipient &quot;<AddRecipient>&quot;
    'Repeat for however many recipients needed
    l_docDocument.RoutingSlip.AddRecipient &quot;<AddRecipient>&quot;
    l_docDocument.RoutingSlip.Delivery = wdAllAtOnce
    'Send
    l_docDocument.Route
End Sub

Dunno if it'll send to outside recipients but worht a try (can't test here - we're on LoNo)

HTH

Cheers
Nikki
 
BTW, mosify these two lines (i forgot to add the values!)

Code:
    l_docDocument.HasRoutingSlip = True
    l_docDocument.RoutingSlip.Subject = &quot;This is the subject&quot;


Cheers
Nikki
 
and for completeness sake add
Code:
Set l_docDocument = Nothing
just before the
Code:
End Sub

Cheers
again (last time i promise ;-))
Nikki
 
Thanks - I now have that code and it works fine except that the code is attached to a button and that button is in a template - when you open the template ie new by double clicking it the button's code does not exist in the word document : (
Any ideas on persistence of code from tempates to their documents ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top