2013-02-01 73 views
-1

感謝Stack Overflow用戶,他幫助我將此圖表轉換爲電子郵件附件。非常感謝。我的下一步是試圖將它作爲圖像或副本進入電子郵件的實際主體。當附件有效時,演示文稿在內容中會更好,除了電子郵件以外沒有其他任何東西可以打開。任何人有任何建議?我還沒有聽說有關嘗試使用Lotus進行此操作的很多好處。將圖表嵌入Lotus Notes電子郵件正文

Sub SendEmail() 
    ' setting up various objects 
    Dim Maildb As Object 
    Dim UserName As String 
    Dim MailDbName As String 
    Dim MailDoc As Object 
    Dim Session As Object 
    Dim recipient As String 
    Dim ccRecipient As String 
    Dim bccRecipient As String 
    Dim subject As String 
    Dim bodytext As String 
    Dim User As String 
    Dim Fname As String 




    User = Application.UserName 

    ' setting up all sending recipients 
    recipient = "[email protected]" 
    'ccRecipient [email protected] 
    'bccRecipient = "" 
    subject = "Week-To-Date GM%" 
    bodytext = "" & vbLf & _ 
       "" & vbLf & _ 
       "Here is a breakdown of your total GM% for this week. The graph gives you the GM% by day, with the WTD% displayed as " & vbLf & _ 
       "individual points on the graph. We will continue to develop this report for you to provide you with better information." 




    ' creating a notes session 
    Set Session = CreateObject("Notes.NotesSession") 
    UserName = Session.UserName 
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf" 
    Set Maildb = Session.GETDATABASE("", MailDbName) 

    If Maildb.IsOpen <> True Then 
     On Error Resume Next 
     Maildb.OPENMAIL 
    End If 

    Set MailDoc = Maildb.CreateDocument 
    MailDoc.Form = "Memo" 

    Fname = Environ$("temp") & "\GM1%.jpeg" 

    Sheets("Chart").Shapes("Chart 2").Chart.Export Filename:=Fname, FilterName:="JPEG" 

    ' loading the lotus notes e-mail with the inputed data 
    With MailDoc 
     .SendTo = recipient 
     '.copyto = ccRecipient 
     '.blindcopyto = bccRecipient 
     .subject = subject 
     .Attachment.Add Fname 
     .Body = bodytext 
    End With 


    ' saving message (Change to True if you want to save it) 
    MailDoc.SaveMessageOnSend = False 

     Attachment1 = Worksheets("Chart").Shapes("Chart 2").ChartArea 

    ' send e-mail 
    MailDoc.PostedDate = Now() 
    ' if error in attachment or name of recipients 

     Dim rtitem As Object 
     Dim object As Object 

     Set rtitem = MailDoc.CreateRichTextItem("Attachment1") 
     Set object = rtitem.EmbedObject(1454, "", Fname) 

    MailDoc.Send 0, recipient 

    Kill (Fname) 

    Set Maildb = Nothing 
    Set MailDoc = Nothing 
    Set attachMe = Nothing 
    Set Session = Nothing 
    Set EmbedObj1 = Nothing 

    'Unload Me 
    Exit Sub 
End Sub 
+0

關於投票。我一直試圖讓這個工作幾天。這包括試圖找到堆棧溢出的答案。對不起,我沒有詳細說明我所做的所有工作。 – William

回答

2

我相信你只需要改變1454到1453嵌入一個對象,而不是附件。

爲了得到它進入人體後,雖然,改變,創造了豐富的文本項行:

Set rtitem = MailDoc.CreateRichTextItem("Body") 

如果你需要將文本添加到電子郵件的身體,你可以使用

rtitem.AppendText("text") 
+0

感謝您的回覆。不是在我現在可以測試的環境中,但是我非常感謝它的幫助! – William

+0

我做了推薦的調整,它刪除了附件,但沒有嵌入圖像。 – William

+0

你能否更新上面的代碼以顯示它現在的外觀? –

相關問題