提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何发送电子邮件复制和粘贴指定的范围到电子邮件正文在Excel中?

在许多情况下,Excel工作表中指定的内容范围可能对您的电子邮件通信非常有用。 在这篇文章中,我们将介绍一种直接在Excel中发送具有指定区域粘贴到电子邮件正文中的电子邮件的方法。

在Excel中发送粘贴到电子邮件正文中的指定范围的电子邮件

Office选项卡在Office中启用选项卡式编辑和浏览,使您的工作更轻松......
Kutools for Excel - 最佳办公生产力工具将解决您的大部分Excel问题
  • 重用任何东西: 将最常用或最复杂的公式,图表和其他任何内容添加到您的收藏夹中,并在将来快速重复使用它们。
  • 超过20文本功能: 从文本字符串中提取数字; 提取或删除部分文本; 将数字和货币转换为英语单词...
  • 合并工具:多个工作簿和表格合二为一; 合并多个单元格/行/列而不丢失数据; 合并重复行和总和...
  • 拆分工具:根据价值将数据拆分为多个表格; 一个工作簿到多个Excel,PDF或CSV文件; 一列到多列......
  • 粘贴跳过 隐藏/过滤行; 数和总和 按背景颜色; 创建邮件列表和 通过Cell的价值发送电子邮件...
  • 超级过滤器: 创建高级过滤方案并应用于任何工作表; 排序 按周,日,频率等; 筛选 通过大胆,公式,评论......
  • 超过300强大的功能; 适用于Office 2007-2019和365; 支持所有语言; 在公司轻松部署; 全功能60天免费试用。

在Excel中发送粘贴到电子邮件正文中的指定范围的电子邮件


以下VBA代码可以帮助您复制范围并将其直接粘贴到Excel中的电子邮件正文中。 请做如下。

1。 在工作表中包含您需要复制的范围,请按 其他 + F11 键同时打开 Microsoft Visual Basic for Applications 窗口。

2。 在开幕式上 Microsoft Visual Basic for Applications 窗口,请点击 > 参考文献 如下图所示。

3。 在里面 参考 - VBAProject 对话框,请查找并检查 Microsoft Outlook对象库 选项,然后单击 OK 按钮。

4。 点击 插页 > 模块,然后将下面的VBA代码复制并粘贴到模块窗口中。

VBA代码:在Excel中发送粘贴到电子邮件正文中的指定范围的电子邮件

Sub Send_Email()
    Dim xRg As Range
    Dim I, J As Long
    Dim xAddress As String
    Dim xEmailBody As String
    Dim xMailOut As Outlook.MailItem
    Dim xOutApp As Outlook.Application    
    On Error Resume Next
    xAddress = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Please select range you need to paste into email body", "KuTools For Excel", xAddress, , , , , 8)
If xRg Is Nothing Then Exit Sub
Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    For I = 1 To xRg.Rows.Count
        For J = 1 To xRg.Columns.Count
            xEmailBody = xEmailBody & "  " & xRg.Cells(I, J).value
        Next
        xEmailBody = xEmailBody & vbNewLine
    Next
    xEmailBody = "Hi" & vbLf & vbLf & " body of message you want to add" & vbLf & vbLf & xEmailBody & vbNewLine
    With xMailOut
        .Subject = "Test"
        .To = "happy.xuebi@163.com"
        .Body = xEmailBody
        .Display
        '.Send
    End With
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub

笔记:

1)。 请更改电子邮件正文 xEmailBody =“Hi”&vbLf&vbLf&“您要添加的邮件正文”&vbLf&vbLf&xEmailBody&vbNewLine 如你所需。

2)。 请指定您的电子邮件收件人和主题 .To = happy.xuebi@163.com .Subject =“测试” 代码中的行。

5。 按 F5 键来运行代码。 在弹出 Kutools for Excel 对话框中,请选择您需要粘贴到电子邮件正文中的范围,然后单击 OK 按钮。 看截图:

6。 现在用指定的收件人,主题,正文和选定的Excel范围创建电子邮件,请点击 发送 按钮发送此电子邮件。 见所示的截图。

注意:当您使用Outlook作为您的电子邮件程序时,VBA代码才起作用。


相关文章:


Kutools for Excel - 最佳办公生产力工具提高80%的生产力

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Ther · 26 days ago
    Hi experts, Do we have updates on how the format maintained?
    • To post as a guest, your comment is unpublished.
      crystal · 15 days ago
      Hi Ther,
      Can't figure it out. Sorry for that.
  • To post as a guest, your comment is unpublished.
    Gowtham · 1 months ago
    i am seeing a compile error (User-defined type not defined". Please help me out to overcome this.
    • To post as a guest, your comment is unpublished.
      crystal · 15 days ago
      Hi,
      Please get into the Reference window by clicking Tools > references. Scroll down to find and check the Microsoft Outlook Object Library box and click the OK button to finish the setting.
  • To post as a guest, your comment is unpublished.
    sachin kumr · 4 months ago
    this is pasting as a text. Kindly suggest how to send the table or the same format which is copied from the excel.
  • To post as a guest, your comment is unpublished.
    miguel · 5 months ago
    Code to send automatically after selecting after ok
  • To post as a guest, your comment is unpublished.
    Dhiraj Mahajan · 7 months ago
    Hi
    This code is vary excellent, by using the code i have completed my 90% of my project.
    I have same issue as mentioned by Anirudh that is table formatting. How can i format the table in email.
    Please help me......
    • To post as a guest, your comment is unpublished.
      crystal · 7 months ago
      Good Day,
      The problem can't be solved yet. Sorry for the inconvenience and thank you for your comment.
      • To post as a guest, your comment is unpublished.
        Dhiraj Mahajan · 4 months ago
        Hi, Is there any update on below.......
        • To post as a guest, your comment is unpublished.
          Dhiraj Mahajan · 4 months ago
          Hi, Also I Wanted code for "Filter by Date".
          I am working on project, on that project I wanted to filter the data by the date, actually we have filter/hide the and last 05 days to current date data and we have highlight all other data.
          Please help me to complete this project.
          Your help is very great-full for me.
  • To post as a guest, your comment is unpublished.
    Anirudh · 11 months ago
    This is great. It is working as expected. The only issue is that the format of the table is not maintained in the mail. Can you let me know how do we preserve the format of the table in the mail
  • To post as a guest, your comment is unpublished.
    Michael Ferguson · 1 years ago
    This code is great, but I need to execute with a command button rather than pressing F5 in code view. I'd like my employees to be able to fill out some info, then hit the button and have it copy the range of cells they completed and paste into email. I can get code working for the email button and separately for the copy/paste of the range of cells, but can't seem to combine both functions. Please help!!! Thanks!
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Michael,
      You just need to create a button (such as a Button (Form Control)) in your worksheet, then assign the macro to the button.