2016-08-10 1 views
1

이 코드를 완료하여 Outlook 전자 메일의 본문을 채우지 만 이미 Outlook에서 만든 기존 서명 블록을 어떻게 사용할 수 있는지 알 수 없습니다. 새 답장 또는 전달 전자 메일을 만들 때 서명이 있지만이 코드로 전자 메일을 만들면 나타나지 않습니다. 내가 여기서 달성하고자하는 것은이 코드로 작성된 전자 메일에 내 서명 (또는 해당 서명을 포함)을 표시하는 것입니다.기존 서명 블록을 Word VBA의 Outlook .htmlbody에 삽입하는 방법

Sample email with desired signature

Private Sub emailbutton_Click() 
    'No-option email sending 
    Dim OL    As Object 
    Dim EmailItem  As Object 
    Dim Doc    As Document 

    Application.ScreenUpdating = False 
    Set OL = CreateObject("Outlook.Application") 
    Set EmailItem = OL.CreateItem(olMailItem) 
    Set Doc = ActiveDocument 


    If VName.Value = "" Then 
     Doc.SaveAs ("Quotation_Blank 2016") 
    Else 
     Doc.SaveAs2 ("QFORM" & "_" & JNumber.Value & "_" & VName.Value) 

    End If 


    With EmailItem 
     .Subject = "QFORM" & "_" & JNumber.Value & "_" & VName.Value 

     'HTMLbody 
     msg = "<b><font face=""Times New Roman"" size=""3"" color=""blue"">INTEGRATED ASSEMBLY </font></b><br>" _ 
     & " 1200 Woodruff Rd.<br>" _ 
     & " Suite A12<br>" _ 
     & " Greenville, SC 29607<br><br>" _ 
     & "We have recently released subject project, which will contain assemblies to be outsourced. You have been selected to build these assemblies according to the attachment.<br><br>" _ 
     & "As part of this process, please review the quotion form attached and inidcate your acceptance. If adjustments and-or corrections are required please feel free to contact us for quick resolution.<br><br>" _ 
     & "<b><font face=""Times New Roman"" size=""3"" color=""Red"">NOTE: </font></b>" _ 
     & "The information on attached quotation form is not a contract and only an estimate of predetermined costs per hourly rate for outsource assemblies. <br><br>" _ 
     & "*******For your records you may wish to print out the completed quote form. <br><br>" _ 
     & "Thank you, <br><br>" _ 
     & "<b>HARTNESS INTERNATIONAL </b><br>" _ 
     & "H1 Production Control" & vbNewLine & Signature 


     .HTMLBody = msg 

     If VName.Value = "INTEGRATED ASSEMBLY" Then 
      .To = "XXX.com;" 
      .CC = "XXX.com;" & "XXX.com;" 
      .Importance = olImportanceNormal 'Or olImportanceHigh Or   olImportanceLow 
      .Attachments.Add Doc.FullName 
      .Display 
     ElseIf VName.Value = "LEWALLEN" Then 
      .To = "XXX.com;" 
      .CC = "XXX.com;" & "XXX.com;" 
      .Importance = olImportanceNormal 'Or olImportanceHigh Or   olImportanceLow 
      .Attachments.Add Doc.FullName 
      .Display 

     End If 
    End With 

    Application.ScreenUpdating = True 

    Set Doc = Nothing 
    Set OL = Nothing 
    Set EmailItem = Nothing 
End Sub 

답변

0

나는 당신이 MSG를 삽입 한 후 다시 .HTMLBody를 호출 할 필요가 있다고 생각합니다. 그래서 예를 들면

:

.HTMLBody = msg & .HTMLBody 

이 서명을 받아야합니다. 나는 왜 프로그래밍을 충분히 깊이 생각하지는 못한다.

+0

msg와 함께 .HTMLBody를 호출했지만 서명을 입력하지 않았습니다. Outlook에서 전자 메일을 실행하는 방법은 변경되지 않았습니다. 어느 쪽이든, 제안 주셔서 감사. –

0

Option Explicit이 모듈에 설정되어 있습니까?

서명을 설정했거나 선언했기 때문에 비어 있거나 오류 메시지가 표시되지 않습니다.

는이 같은

뭔가

With EmailItem 
    .Display 
    signature = .body 
    .Subject = "QFORM" & "_" & JNumber.Value & "_" & VName.Value 
' and so on .. 

`

+0

Dbmitch, 방금 당신의 메시지를 보았습니다. 정확히하고 있었고 내 대답을 게시했습니다 –

+0

처음에는 작동하지 않았습니다. 나는 모든 메시지가 작동하도록 첫 번째 주석의 첫 번째 vervair에서 제안한대로 내 메시지로 .HTMLBody를 회상해야했습니다. 도움을 주신 모든 분들께 감사드립니다. –

0

코드가 입력이 성공적으로 완료되었습니다 작동합니다 당신이 빈 몸으로 당겨 먼저 검색 할 필요가 있다고 생각 with 문을 사용하여 EmailItem을 표시하고 msg를 따라 .HTMLBody를 호출합니다. 아래의 전체 코드를 참조하십시오.

Private Sub emailbutton_Click() 
    'No-option email sending 
    Dim OL    As Object 
    Dim EmailItem  As Object 
    Dim Doc    As Document 

    Application.ScreenUpdating = False 
    Set OL = CreateObject("Outlook.Application") 
    Set EmailItem = OL.CreateItem(olMailItem) 
    Set Doc = ActiveDocument 

    With EmailItem 
    .Display 
    End With 
     Signature = EmailItem.body 


    With EmailItem 
     .Subject = "QFORM" & "_" & JNumber.Value & "_" & VName.Value 

     'HTMLbody 
     msg = "<b><font face=""Times New Roman"" size=""4"" color=""blue"">INTEGRATED ASSEMBLY </font></b><br>" _ 
     & " 1200 Woodruff Rd.<br>" _ 
     & " Suite A12<br>" _ 
     & " Greenville, SC 29607<br><br>" _ 
     & "We have recently released subject project, which will contain assemblies to be outsourced. You have been selected to build these assemblies according to the attachment. <br><br>" _ 
     & "As part of this process, please review the quotation form attached and indicate your acceptance. If adjustments and-or corrections are required, please feel free to contact us for quick resolution. <br><br>" _ 
     & "<b><font face=""Times New Roman"" size=""4"" color=""Red"">NOTE: </font></b>" _ 
     & "The information on attached quotation form is not a contract and only an estimate of predetermined costs per hourly rate for outsource assemblies. <br><br>" _ 
     & "*******For your records you may wish to print out the completed quote form. <br><br>" _ 
     & "Thank you, <br><br>" _ 
     & "<b>HARTNESS INTERNATIONAL </b><br>" _ 
     & "H1 Production Control <br>" _ 
     & vbNewLine & Signature 

     .HTMLBody = msg & .HTMLBody 

     If VName.Value = "INTEGRATED ASSEMBLY" Then 
      .To = "[email protected];" 
      .CC = "[email protected];" & "[email protected];" 
      .Importance = olImportanceNormal 'Or olImportanceHigh Or   olImportanceLow 
      .Attachments.Add Doc.FullName 
      .Display 
     ElseIf VName.Value = "LEWALLEN" Then 
      .To = "[email protected];" 
      .CC = "[email protected];" & "[email protected];" 
      .Importance = olImportanceNormal 'Or olImportanceHigh Or   olImportanceLow 
      .Attachments.Add Doc.FullName 
      .Display 

     End If 
    End With 


    If VName.Value = "" Then 
     Doc.SaveAs ("Quotation_Blank 2016") 
    Else 
     Doc.SaveAs2 ("QFORM" & "_" & JNumber.Value & "_" & VName.Value) 

    End If 

    Application.ScreenUpdating = True 

    Set Doc = Nothing 
    Set OL = Nothing 
    Set EmailItem = Nothing 
End Sub