将签名添加到电子邮件Outlook

时间:2015-09-08 13:33:57

标签: vb.net outlook

嘿我试图将我的默认签名添加到自动生成的电子邮件中,我能够做到的唯一方法就是使用.Display(Mailitem)并从中获取签名。

我想知道是否有其他方法可以做到这一点,不涉及显示任何内容。

If sEmailAddress.Contains("@") Then
    Dim objOutlook As Object
    Dim objMailMessage1 As Outlook.MailItem
    Dim signature As String
    objOutlook = CreateObject("Outlook.Application")
    objMailMessage1 = objOutlook.CreateItem(0)
    With objMailMessage1
        .To = "richard@Sortmypc.co.uk"
        .Display(objMailMessage1)
        '  .Close()
        signature = .HTMLBody
        .HTMLBody = "<p>" & sEmailGreeting & " " & sLeadName & "</p>" & vbCrLf & vbCrLf & "<p> Many Thanks for your enquiry, I can confirm our fee to carry out the Home Report would be " & "£" & sHomeReportTotal & " including VAT.</p>" & vbCrLf & vbCrLf & "<p> We provide Home Reports at a time to suit you with early morning, evening and weekend appointments. <b> We have availability this week/weekend </b> and are more than happy to have a chat whenever is convenient with you and talk you through the home report process. </b>" & vbCrLf & vbCrLf & "<p><font color=red> Our team of in-house RICS qualified Surveyors </font> who all have local knowledge and provide a professional service.  The Home Report Company also prides itself on a quick turnaround, so unlike some traditional chartered surveying practice we also ensure that all reports are with our clients within 2 working days.</P>" & vbCrLf & vbCrLf & "<p>Fully insured and regulated by RICS, we understand that selling your home can be an expensive and stressful time and we want to take some of that pressure away from you. So that is why we are open from early in the morning until late in the evening as well as at the weekends so if you have any questions regarding your Home Report then there is someone here to answer those questions.</p>" & vbCrLf & vbCrLf & "<p>We also understand Home Report Costs can be expensive and that is why we are one of the most competitive in the market.</p>" & vbCrLf & vbCrLf & "<p>Once again we thank you for your enquiry, and if you have any questions please let me know</P>" & vbCrLf & vbCrLf & "<p>Look forward to hearing from you.</p>" & vbCrLf & vbCrLf & "<p>Kind Regards </p>" & vbCrLf & vbCrLf & "<p>Louise</p>" & "<p>" & signature & "</p>"
        .Subject = "Scottish Home Reports quote -" & sLeadName

        '  .Display()
        '  .Save()
        .Send()
        sEmailSent = "Good Evening " & sLeadName & "" & vbCrLf & vbCrLf & "Many Thanks for your enquiry, I can confirm our fee to carry out the Home Report would be " & "£" & sHomeReportTotal & " including VAT." & vbCrLf & vbCrLf & "We provide Home Reports at a time to suit you with early morning, evening and weekend appointments.  We have availability this week/weekend and are more than happy to have a chat whenever is convenient with you and talk you through the home report process." & vbCrLf & vbCrLf & "Our team of in-house RICS qualified Surveyors who all have local knowledge and provide a professional service.  The Home Report Company also prides itself on a quick turnaround, so unlike some traditional chartered surveying practice we also ensure that all reports are with our clients within 2 working days." & vbCrLf & vbCrLf & "Fully insured and regulated by RICS, we understand that selling your home can be an expensive and stressful time; and we want to take some of that pressure away from you. So that is why we are open from early in the morning until late in the evening as well as at the weekends so if you have any questions regarding your Home Report then there is someone here to answer those questions." & vbCrLf & vbCrLf & "We also understand Home Report Costs can be expensive and that is why we are one of the most competitive in the market." & vbCrLf & vbCrLf & "Once again we thank you for your enquiry, and if you have any questions please let me know" & vbCrLf & vbCrLf & "Look forward to hearing from you." & vbCrLf & vbCrLf & "Kind Regards" & vbCrLf & vbCrLf & "Louise"
    End With
    SaveLead()
End If

1 个答案:

答案 0 :(得分:-1)

如果您在Outlook中创建签名,它会将三个文件(HTM,TXT和RTF)保存到:

 C:\Users\<UserName>\AppData\Roaming\Microsoft\Signatures

您可以使用以下代码获取签名内容:

 Function GetBoiler(ByVal sFile As String) As String
  Dim fso As Object
  Dim ts As Object
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
  GetBoiler = ts.readall
  ts.Close
 End Function

有关详细信息和示例代码,请参阅Insert Outlook Signature in mail