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

or

工作簿保存在Excel中时如何通过Outlook发送电子邮件?

本文讨论在Excel中保存特定工作簿时通过Outlook发送电子邮件。 请按照教程所示进行。

使用VBA代码保存工作簿时,通过Outlook发送电子邮件

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

使用VBA代码保存工作簿时,通过Outlook发送电子邮件


将工作簿保存在Excel中时,要通过Outlook发送电子邮件,请按照以下步骤操作。

1。 请首先将工作簿保存为Excel宏功能工作簿。 点击 文件 > 另存为。 在 另存为 对话框中,选择一个文件夹来保存工作簿,将其命名为“文件名”框,然后选择 Excel宏启用工作簿 来自 保存类型 下拉列表,然后单击 保存 按钮。 看截图:

2。 打开刚刚保存的Excel宏功能工作簿,按 其他 + F11 键同时打开 Microsoft Visual Basic for Applications 窗口。

2。 在里面 Microsoft Visual Basic for Applications 窗口,请双击 的ThisWorkbook 在左侧栏中,然后复制并粘贴下面的VBA代码 的ThisWorkbook 代码窗口。 看截图:

VBA代码:保存工作簿时发送电子邮件

Private Sub Workbook_AfterSave(ByVal Success As Boolean)
'Updated by Extendoffice 20181102
    Dim xOutApp As Object
    Dim xMailItem As Object
    Dim xName As String
    On Error Resume Next
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailItem = xOutApp.CreateItem(0)
    xName = ActiveWorkbook.FullName
    With xMailItem
        .To = "Email Address"
        .CC = ""
        .Subject = "The workbook has been saved"
        .Body = "Hi," & Chr(13) & Chr(13) & "File is now updated."
        .Attachments.Add xName
        .Display
       '.send
    End With
    Set xMailItem = Nothing
    Set xOutApp = Nothing
End Sub

注意:请替换 电邮地址 与收件人的电子邮件地址一致 .To =“电子邮件地址”根据需要更改VBA代码中的Cc,主题以及主体字段。

3。 按 其他 + Q 键同时关闭 Microsoft Visual Basic for Applications 窗口。

从现在开始,当您更新工作簿并保存时,会自动创建电子邮件并附带更新的工作簿。 请点击 发送 按钮发送电子邮件。 看截图:

注意:当您使用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.
    Mike · 1 months ago
    Is there a way to have the automated email be auto encrypted?
    • To post as a guest, your comment is unpublished.
      crystal · 15 days ago
      Hi Mike,
      Sorry can't help to solve this problem. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    mayle4pam · 2 months ago
    How would this be handled for an Office 365 document. It is automatically saving.
  • To post as a guest, your comment is unpublished.
    Chris · 11 months ago
    Hi, nice article! One thing ive been trying to achieve with this is to attach the current state of the workbook to the email.

    At the moment, it only sends the original state of the file and doesnt include any changes the user would have made.

    Any ideas on how to implement this using a macro?
    • To post as a guest, your comment is unpublished.
      crystal · 10 months ago
      Hi Chris,
      The code has been updated with the problem solved, please have a try. Thank you for your comment.
      • To post as a guest, your comment is unpublished.
        Tin Hwee Lee · 5 months ago
        Hi Chris,

        I have chanced upon the same issue.
        Currently the codes are used in the "beforesave" module.
        Which means that the email will send the spreadsheet that is before saved.

        There is another module "aftersave".
        I applied the code in this module and it worked like a charm.
  • To post as a guest, your comment is unpublished.
    Robert · 1 years ago
    Dear all, I would like to ask how to attach functional link to certain folder on server, if I paste the link, it appears in the workbook just like plain text and so it doensn't work in received e-mail, how can I turn it into link, so recepiants can click on it?
    I would like to use this way instead sending enclosed excel file.
    Thanks for advice
    • To post as a guest, your comment is unpublished.
      Grant · 6 months ago
      I put this in the body of the email and it worked for me...
      "file:///Z:\dir1\dir2\dir3\Test1.xlsm"
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Robert,
      Sorry can’t help with this, welcome to post any question about Excel to our forum: https://www.extendoffice.com/forum.html. You will get more Excel supports from our professional or other Excel fans.
  • To post as a guest, your comment is unpublished.
    Antonio · 1 years ago
    Gracias. Consulta: utilizando esta misma rutina, como podría enviar el correo a un correo específico dependiendo el valor de otra celda?
  • To post as a guest, your comment is unpublished.
    Jermaine · 1 years ago
    How to automate the email notification in VBA based on Date range, without having to see the pop up for security permission to allow VBA to send the email.