outlook2007自动追加签名和日期

outlook里的任务,日程,联系人等很是喜欢,而且能与我的手机同步信息,所以决定改用outlook2007。装上后发现一个问题,在个人签名里不能像foxmail一样自己添加发信日期,很是郁闷。google一番后决定用vba实现,步骤如下:

 

点"工具"->"宏"->"Visual Basic编辑器",打开后点双击左边"Project1"下的"ThisOutlookSession",在打开的空白页里添加如下代码

 

Dim myOlApp As New Outlook.Application Private WithEvents myOlInspectors As Outlook.Inspectors Private myMailItem As Outlook.MailItem Function Signature() As String Dim mDate As Date mDate = Format(Now, "yyyy-MM-dd") Signature = Signature & "<br /><br /><br />---------------------------------------------------------------<br/>" Signature = Signature & "某某某<br />" Signature = Signature & mDate & " <br />" End Function Private Sub Application_Startup() 'GetSignature Set myOlInspectors = myOlApp.Inspectors End Sub Private Sub myOlInspectors_NewInspector(ByVal Inspector As Inspector) Dim str As String str = TypeName(Inspector.CurrentItem) If str = "MailItem" Then Set myMailItem = Inspector.CurrentItem With myMailItem .HTMLBody = .HTMLBody & Signature() End With End If End Sub

 

原来google到的代码没有对打开的窗体的类型进行判断,所以会导致打开任务或者日程时报错,我自己加上了这个判断。

你可能感兴趣的:(outlook2007自动追加签名和日期)