VBA實現Outlook自動發送帶附件帶簽名的工作周報,vba工作周報
' 閑話少說 直接上代碼:
Sub zhoubao() Dim outapp As Object Dim outmail As Object Dim body As String Dim fname As String Set outapp = CreateObject("Outlook.Application") '不使用模板 'Set outmail = outapp.CreateItem(0) '使用模板 Set outmail = outapp.CreateItemFromTemplate("C:\Users\Administrator\AppData\Roaming\Microsoft\Templates\2014年周工作總結與安排(周海清).oft") '附件 fname = "D:\E\workspaces\3_公司\2_上報公司\1_工作周報\2014年周工作總結與安排(周海清).xlsx" '本文 body = "<H3><B>Hi ,</B></H3>" & _ "Please see attached!<br>" & _ "<br><br><B></B>" & _ GetSignature() On Error Resume Next With outmail .To = "xxx@chenzhimr.com" '收件者 .CC = "xx@czcinfo.com" '抄送人 .BCC = "" '密送人 .Subject = "2014年周工作總結與安排(周海清)——" & Now '標題 .HTMLBody = body '.body = body .Attachments.Add fname .Send 'or use .Display End With On Error GoTo 0 MsgBox ("Sent successfully!") Set outmail = Nothing Set outapp = Nothing ErrMsg: MsgBox (Err.Description) End SubPublic Function GetSignature()Dim fso As ObjectSet fso = CreateObject("Scripting.FileSystemObject")SigPath = "C:\Users\Administrator\AppData\Roaming\Microsoft\Signatures\標準_CN.htm"Set f_SignatureObj = fso.OpenTextFile(SigPath, 1, False, 0)GetSignature = f_SignatureObj.ReadAllf_SignatureObj.CloseSet fso = NothingEnd Function
OutLook 2010 怎使用VBA實現:當你寫完一封郵件,點擊發送時,判斷有沒有附件
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim myOlApp As New Outlook.Application
Dim myItem As Outlook.MailItem
Dim myAttachments As Outlook.Attachments
Dim cancelsend As Long
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
If myItem.Attachments.Count = 0 Then
cancelsend = MsgBox(" 是否忘記粘貼附件了 !" & vbNewLine & vbNewLine & " 確定要發送嗎?", _
vbYesNo + vbDefaultButton2 + vbQuestion, "忘記粘貼附件提示")
If cancelsend = vbNo Then Cancel = True
End If
End Sub
outlook裡發送郵件時的自動簽名,再回覆寄件者時不會出現
以outlook 2010為例,你可以點擊左上方的“開始”--“建立電子郵件”,然後你會看到上面一排有個“簽名”的按鈕,點擊那個小三角,出現下拉式功能表,選擇最底下一行的“簽名”,彈出新的對話方塊,在右側有個“選擇預設簽名”,除了那個“新郵件”要選擇相應的簽名,不要忘了“回覆/轉寄”也要選擇對應的簽名哦……都看了吧?應該知道怎麼做了吧?呵呵……不複雜的,2007情況也差不多的,有問題再問。