我是使用Visual Basic的新手。我在MS Excel中使用Visual Basic。我正在努力解决必须将屏幕截图粘贴到电子邮件中。我有以下内容,请您告诉我需要输入的内容。
由于
Sub AddToNaughtyList()
'
' AddToNaughtyList Macro
'
Range("Y3:Z3").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("U2:V2").Select
Selection.Copy
Range("Y3:Z3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E2").Select
Dim aOutlook As Object
Dim aEmail As Object
Dim StudentName As String
Dim SendAddress As String
' copy picture
Range("C6:S39").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
'setup email
Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
StudentName = ActiveCell.Value
SendAddress = Range("D5")
'Cells(1, "A").Value
'Set Address
aEmail.To = SendAddress
'Set Subject
aEmail.Subject = "Weekly Progress Report for " & StudentName
'Set Body for mail
aEmail.HTMLBody = "<font face=calibri><html><body>Nat's *Student needs to attend Friday Detention* text goes here.</font><br /><br />" _
'paste into email???????????
aEmail.Display
答案 0 :(得分:0)
我看到了两种可能的解决方案:
例如:
Attachment attachment = newMail.Attachments.Add(@"E:\Pictures\image001.jpg", OlAttachmentType.olEmbeddeditem, null, "Some image display name");
string imageCid = "image001.jpg@123";
attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", imageCid);
newMail.HTMLBody = String.Format("<body><img src=\"cid:{0}\"></body>", imageCid);