このコードは、Microsoft Outlookの2010償還
と償還のライブラリを使用して、MS Accessの(2010)VBAである私は、このプロセスは、前に働いていましたしかし、私は最近、私のOutlookで何かをリセットしたと思われるCitrixのアップグレードがありました。
私はこれは私が前にやっていたものであるなど.msgのすべての適切な形式と基本的にあらかじめ用意された電子メールテンプレートにあるファイル、画像、テキスト、のフォルダ
を持っている:
Dim outlookApp As Object, namespace As Object
Dim oItem, MyItem
Set outlookApp = CreateObject("Outlook.Application")
Set namespace = outlookApp.GetNamespace("MAPI")
namespace.Logon
Set MyItem = outlookApp.CreateItemFromTemplate(path_to_dot_msg_file)
'And then there are many calls like this:
MyItem.HTMLBody = Replace(MyItem.HTMLBody, "Dear Person,", "Dear " & name)
'...
Set safeItem = CreateObject("Redemption.SafeMailItem")
Set oItem = MyItem
safeItem.Item = oItem
'this next line displays the email, and as of this line, it looks correct
'safeItem.Display
'but as of this line, the issue occurs
safeItem.HTMLBody = "<p>This is an extra message that shows up before the .msg file</p>" & safeItem.HTMLBody
safeItem.Recipients.ResolveAll
safeItem.Send
電子メールが送信されると、.msgの内容はまったく表示されません。唯一表示されるのは、HTMLBodyにプリペンドした「余分なメッセージ」だけです。
変更または更新する必要はありますか?これはコードや私のOutlookの設定などで変更する必要がありますか?
エクストラ:身体の挿入:
Function insertStringBodyTag(htmlBody As String, stringToInsert As String)
Dim s As String
Dim i As Integer
s = htmlBody
i = InStr(1, s, "<body")
i = InStr(i, s, ">")
s = Left(s, i) & stringToInsert & Right(s, Len(s) - i)
insertStringBodyTag = s
End Function
'Called with safeItem.htmlBody = insertStringBodyTag(safeItem.htmlBody, prefix_string)
私はそれを試みましたが、動作しません(htmlbodyは空白になりますか?)。私はポストに自分のコードを追加して、私の意味を示しました。 – user7285972
戻ったときのinsertStringBodyTagの値は何ですか? –
入力時に空白に見えます。さらに、safeItemをmyItemに設定すると、属性/ HTMLbodyを継承しません – user7285972