通过 Excel VBA 在 Outlook 中打开新邮件 [英] Open new message in Outlook by Excel VBA

查看:54
本文介绍了通过 Excel VBA 在 Outlook 中打开新邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每天都在处理每日报告.这是相当耗时的.基本上,我需要发送包含昨天与上周和上个月销售额的简要比较的电子邮件.这工作得很好.完成此操作后,消息将粘贴到新工作表中,然后我必须将其复制并粘贴到 Outlook 中的新电子邮件中.

everyday I am handling daily reporting. Which was quite time consuming. Basically I need to send email containing brief comparison of sales yesterday with sales last week and month. That is working pretty well. Once this is done the message is pasted to new sheet and then I have to copy it and paste into new email in Outlook.

是否可以创建宏来在 Outlook 中打开新邮件?这样我就可以插入我的文本了.我能够编写直接从 Excel 发送的宏,但这并不是我真正想要的,因为报告的某些部分必须通过手动查看数字来完成.

Is there a possibility to create macro that will open new message in Outlook? So I'll be able to insert my text. I am able to write macro that will send it directly from Excel but this is not something I really want to as some part of the reporting must by done by looking at numbers manually.

非常感谢!

推荐答案

我找到了这个,而且运行良好!!!!

I've found this one and it is working perfectly!!!!

也许只是一件额外的事情 - 是否可以将打开的文档附加为附件?

Just maybe one extra thing - is there a possibility to attach opened document as a attachment?

Sub CustomMailMessage()
Dim OutApp As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Recipient
Dim Recipients As Recipients

  Set OutApp = CreateObject("Outlook.Application")
  Set objOutlookMsg = OutApp.CreateItem(olMailItem)

  Set Recipients = objOutlookMsg.Recipients
  Set objOutlookRecip = Recipients.Add("alias@domain.com")
  objOutlookRecip.Type = 1

  objOutlookMsg.SentOnBehalfOfName = "sales@domain.com"
  objOutlookMsg.Subject = "Testing this macro"
  objOutlookMsg.HTMLBody = "Testing this macro" & vbCrLf & vbCrLf
  'Resolve each Recipient's name.
  For Each objOutlookRecip In objOutlookMsg.Recipients
    objOutlookRecip.Resolve
  Next
  'objOutlookMsg.Send
  objOutlookMsg.Display

  Set OutApp = Nothing  
End Sub

这篇关于通过 Excel VBA 在 Outlook 中打开新邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆