Office中国论坛/Access中国论坛

标题: [求助]如何用VBA实现(Send to>>Mail Recipient) [打印本页]

作者: laotang    时间: 2006-9-7 20:19
标题: [求助]如何用VBA实现(Send to>>Mail Recipient)

Send To>>Mail Recipient
而不是
Send To>>Mail Recipient (as Attachment...)

[attach]20199[/attach]ThisWorkbook.SendMail() 是按附件方式发送,而我需要的是:收到Mail 后打开MAil Item 即可见Excel的WorkSheet,
Mail Recipient 就可以做到,但我不知道用VBA怎么写。谢谢赐教。 [attach]20200[/attach]




[此贴子已经被作者于2006-9-8 8:53:00编辑过]


作者: 方漠    时间: 2006-9-8 19:58
这个例子可能对你有用,至少可以参考一下,用OUTLOOK发邮件,密码为当前日期(MMDD格式)。也可以自已修改代码把密码去掉。

[attach]20225[/attach]

作者: laotang    时间: 2006-9-8 22:35
多谢方侠。你的例子还是解决不了我的问题。

Excel菜单File>>Send To>>Mail Recipient结果是:打开邮件直接可见到WORKSHEET,没有正文,也没有附件。
作者: 方漠    时间: 2006-9-9 00:20
我的是英文2003的,压根就没看见这个菜单呀,是不是取消掉了?

不过可以试试以下这三种方法。

SendMail Method

See AlsoApplies ToExampleSpecificsSends the workbook by using the installed mail system.

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.

Example

This example sends the active workbook to a single recipient.

ActiveWorkbook.SendMail recipients:="Jean Selva"




SendForReview Method


Sends a workbook in an e-mail message for review to the specified recipients.

expression.SendForReview(Recipients, Subject, ShowMessage, IncludeAttachment)

expression    Required. An expression that returns one of the objects in the Applies To list.

Recipients   Optional Variant. A string that lists the people to whom to send the message. These can be unresolved names and aliases in an e-mail phone book or full e-mail addresses. Separate multiple recipients with a semicolon (;). If left blank and ShowMessage is False, you will receive an error message, and the message will not be sent.

Subject   Optional Variant. A string for the subject of the message. If left blank, the subject will be: Please review "filename   ".

ShowMessage   Optional Variant. A Boolean value that indicates whether the message should be displayed when the method is executed. The default value is True. If set to False, the message is automatically sent to the recipients without first showing the message to the sender.

IncludeAttachment   Optional Variant. A Boolean value that indicates whether the message should include an attachment or a link to a server location. The default value is True. If set to False, the document must be stored at a shared location.

Remarks

The SendForReview method starts a collaborative review cycle. Use the EndReview method to end a review cycle.

Example

This example automatically sends the active workbook as an attachment in an e-mail message to the specified recipients.

Sub WebReview()

    ActiveWorkbook.SendForReview _
        Recipients:="someone@microsoft.com; amy jones; lewjudy", _
        Subject:="lease review this document.", _
        ShowMessage:=False, _
        IncludeAttachment:=True

End Sub





MsoEnvelope Object


Provides access to functionality that lets you send documents as emails directly from Microsoft Office applications.

Using the MsoEnvelope object

Use the MailEnvelope property of the Document object, Chart object or Worksheet object (depending on the application you are using) to return a MsoEnvelope object.

The following example sends the active Microsoft Word document as an e-mail to the e-mail address that you pass to the subroutine.

Sub SendMail(ByVal strRecipient As String)

    'Use a With...End With block to reference the MsoEnvelope object.
    With Application.ActiveDocument.MailEnvelope

        'Add some introductory text before the body of the e-mail.
        .Introduction = "lease read this and send me your comments."

        'Return a Microsoft Outlook MailItem object that
        'you can use to send the document.
        With .Item

            'All of the mail item settings are saved with the document.
            'When you add a recipient to the Recipients collectio
作者: laotang    时间: 2006-9-9 03:19
The SendForReview method 这可能是我要的回去试试,谢谢!




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3