2013-02-01 2 views
-1

이 차트를 전자 메일의 첨부 파일로 가져 오는 데 도움이되는 동료 Stack Overflow 사용자에게 감사드립니다. 대단히 감사합니다. 다음 단계는 이미지 또는 사본으로 이메일의 실제 본문으로 가져 오려고하는 것입니다. 첨부 파일이 작동하는 동안, 프레 젠 테이션은 신체보다 훨씬 좋을 것이고, 이메일 이외의 것을 열어 볼 필요는 없습니다. 누구든지 조언을하나요? 나는 로터스와 함께 이것을 시도하는 것에 대해 많은 좋은 것을들은 적이 없다.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

지금 어떻게 보이는지 보여주기 위해 위 코드를 업데이트 할 수 있습니까? –

관련 문제