我想建立\編輯郵件signiture在Excel中:如何添加Excel範圍爲圖片到Outlook郵件正文
1st cell : |Regards, | 2nd cell (Name) : |Asaf Gilad | 3rd Cell (Title): |PMO | 4th cell (Mail) : |[email protected] |
所以,當我點擊發送,郵件的正文將看如:
Dear sir ................................ ....... Message Content ........ ................................ ................................ Regards, Asaf Gilad PMO [email protected]
簽名包含圖片以及。
我設法將範圍保存爲圖片,並將該圖片作爲附件發送,但圖片原來是空的,因爲它沒有正確地作爲附件發送。
這裏是我使用的代碼:
Public Sub ExportEmail(recipentName As String) On Error GoTo err: Dim olApp As Outlook.Application Dim olNs As Outlook.Namespace Dim olMail As Outlook.MailItem Dim strEmailTo As String, strEmailCC As String, strEmailBCC As String Dim FNAME As String Dim oRange As Range Dim oChart As Chart Dim oImg As Picture strEmailTo = "" strEmailCC = "" strEmailBCC = "" strEmailTo = "[email protected]" strEmailCC = "[email protected] If strEmailTo "" Then Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") olNs.Logon Set olMail = olApp.CreateItem(olMailItem) olMail.To = strEmailTo olMail.CC = strEmailCC olMail.BCC = strEmailBCC olMail.Subject = " My Subject" Set oRange = Sheets(1).Range("A1:Z100") Set oChart = Charts.Add oRange.CopyPicture xlScreen, xlPicture oChart.Paste FNAME = Environ$("temp") & "\testPic.gif" oChart.Export Filename:=FNAME, FilterName:="GIF" olMail.Attachments.Add FNAME olMail.HTMLBody = "" & _ "" olMail.Attachments.Add FNAME olMail.Send End If Application.StatusBar = False Application.ScreenUpdating = True Application.DisplayAlerts = True Kill FNAME Set olApp = Nothing Set olNs = Nothing Set oRange = Nothing Set oChart = Nothing Set oImg = Nothing Exit Sub err: MsgBox err.Description End Sub
當Outlook已經有該向導輕鬆添加簽名時,爲什麼要創建簽名添加程序? – bonCodigo
我還不確定。客戶定義了這種需求。也許他希望我的工具發送的電子郵件的簽名與其他郵件不同。向他詢問原因是個好主意,但我覺得這個excel-outlook任務很有趣。除了目前的任務,它可以幫助我自動化一些郵件撰寫(不能想到很好的例子:可能是報告摘要) –