【问题标题】:How to add screenshot after the text body of outlook email如何在outlook邮件正文后添加截图
【发布时间】:2015-03-18 05:49:22
【问题描述】:
dim objoutlook as object
dim objmail as object
dim rngto as range
dim rngsubject as range
dim rngbody1 as range
set dodata1 = new dataobject

set objoutlook = createobject ("outlook.application")
set objmail = objoutlook.createitem(0)

with activesheet
    set rngto = .range("iv8")
    set rngsubject = .range ("iv9")
    set rngbody1 = .range(.range("a4:i8"), .range("a4").end(xldown))
    rngbody1.copy
    dodata1.getfromclipboard
end with

with objmail
    .to = rngto.value
    .subject = rngsubject.value
    application.sendkeys ("{tab}")
    doevents

    application.sendkeys "(%{1068})"
    doevents

    .display
end with

sendkeys "^({v})", true

with objoutlook = nothing
with objmail = nothing
with rngto = nothing
with rngsubject = nothing
with rngbody1 = nothing

代码将 Excel 单元格粘贴到 Outlook 电子邮件中。在将 Excel 中的数据粘贴到 Outlook 后,我还想添加一个屏幕截图。我已经用sendkeys 尝试过,但这会将屏幕截图粘贴到以前的 Excel 数据上。

谁能建议一种在电子邮件正文下方添加屏幕截图的方法。

【问题讨论】:

    标签: excel ms-word vba


    【解决方案1】:

    在 Excel 2010 中测试的代码

    Private Sub PasteAtEnd()
    
    'Set reference to Outlook in Tools | References
    Dim objOutlook As Outlook.Application
    Dim objMail As Outlook.MailItem   
    Dim myInspector As Outlook.Inspector
    
    'Set reference to Word in Tools | References
    Dim myDoc As Word.Document
    
    On Error Resume Next
    Set objOutlook = GetObject(, "outlook.application")
    On Error GoTo 0
    
    If objOutlook Is Nothing Then
        Set objOutlook = CreateObject("outlook.application")
        Set objMail = objOutlook.CreateItem(0)
        objMail.Display
    End If
    
    ' If outlook is already open,
    '  open a mailitem before running the code
    Set myInspector = ActiveInspector.CurrentItem.GetInspector
    
    ' This line generates a warning message
    Set myDoc = myInspector.WordEditor
    
    ' This simulates existing text
    myDoc.Content.InsertAfter Chr(13) & "Paste Clipboard after all existing Content" & Chr(13)
    
    ' new line
    myDoc.Content.InsertAfter Chr(13)
    
    myDoc.Characters.last.Select
    myDoc.Application.Selection.Paste
    
    Set myInspector = Nothing
    Set myDoc = Nothing
    Set objOutlook = Nothing
    
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2012-12-04
      • 2017-11-26
      • 1970-01-01
      • 2011-07-11
      • 2012-01-18
      • 2016-05-27
      • 2018-10-05
      • 1970-01-01
      • 2019-04-07
      相关资源
      最近更新 更多