0
我已被分配發送聖誕節問候語,這些問候語已定製給特定客戶。然而,這些問候是在100年代,自動實行會節省我幾個小時 - 而這些問候每年都會完成!Excel VBA將單個圖像嵌入電子郵件聯繫人列表
在Excel中,用戶名在列A中列出,在B列的個人電子郵件和路徑列中的個別定製的問候語文件C.
我已經發現目前是VBA代碼,爲我提供了將這些文件通過其路徑附加(但不嵌入)到各個電子郵件的選項。
任何人都可以向我解釋和/或演示如何嵌入通過列C找到的附加文件?
非常感謝!
我現在擁有的是以下幾點:
Sub Send_Files()
'Working in Excel 2000-2016
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
Dim OutApp As Object
Dim OutMail As Object
Dim sh As Worksheet
Dim cell As Range
Dim FileCell As Range
Dim rng As Range
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set sh = Sheets("Sheet1")
Set OutApp = CreateObject("Outlook.Application")
For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConstants)
'Enter the path/file names in the C:Z column in each row
Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1")
If cell.Value Like "?*@?*.?*" And _
Application.WorksheetFunction.CountA(rng) > 0 Then
Set OutMail = OutApp.CreateItem(0)
With OutMail
.to = cell.Value
.Subject = "Merry Christmas!"
.Body = "Merry Christmas!"
For Each FileCell In rng.SpecialCells(xlCellTypeConstants)
If Trim(FileCell) <> "" Then
If Dir(FileCell.Value) <> "" Then
.Attachments.Add FileCell.Value, olByValue, 0
End If
End If
Next FileCell
.Send 'Or use .Display
End With
Set OutMail = Nothing
End If
Next cell
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
你只需要設置filecell是cell.offset(0,1) –
@Nat原諒我的愚蠢,但它去了哪裏?如果它不太苛刻,我可以請你把它寫入代碼,以便我可以複製它。 (這是我第一次使用VBA)。 – Hans
@Nathan_Sav,我給你貼上了錯碼 – Hans