[英]Reading text file and sending mails to outlook using Python
我正在閱讀 Python 代碼中的 .txt 文件,我應該得到與文本文件中相同的郵件正文。 它工作正常,但超鏈接未顯示在我的 outlook email 中,它僅在 outlook Z0C83F57C3731C7EB.AB 中顯示為文本
下面是代碼:
Mail_Content = open("MailBody.txt","r")
Read_Content = Mail_Content.read()
在文本文件中,為超鏈接傳遞這樣的內容:
<a href="link">linkname</a>,'html'
請幫幫我,我正試圖從過去兩天解決這個問題。
首先,您確實需要顯示設置消息正文的代碼。 其次,確保設置MailItem.HTMLBody
而不是純文本MailItem.Body
。
在代碼中設置HTMLBody
屬性之前,請確保BodyFormat
屬性設置正確,例如,這是一個 VBA 示例,它顯示了如何正確設置它:
Sub CreateHTMLMail()
'Creates a new email item and modifies its properties.
Dim objMail As MailItem
'Create mail item
Set objMail = Application.CreateItem(olMailItem)
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><H2>The body of this message will appear in HTML.</H2><BODY>Type the message text here. </BODY></HTML>"
.Display
End With
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.