我有一封电子邮件的以下VBA代码:
Sub Global_Email_Message()
Content = "<style> p {background-color: #d9d9d9} </style><p> This message should be global so I can use it in every sub for an E-Mail </p>"
If ExitAll = False Then
Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
With OMail
.display
End With
signature = OMail.HTMLBody
With OMail
.To = "test@test.de"
.Subject = "test"
.HTMLBody = Content
End With
Set OMail = Nothing
Set OApp = Nothing
Else
End If
End Sub
此代码完美无缺。
现在,我想在变量&#34; Content&#34;中实现消息 和 样式是全球性的,所以我可以在不同的电子邮件子中使用它。如何全球化内容&#34;不同的电子邮件子的变量?
答案 0 :(得分:0)
您需要在函数外部使用public声明内容变量:
Public content as String
Sub Global_Email_Message()
...