VBA enables Outlook to automatically send work weekly reports with attachments and vba work weekly reports
'Let's talk less about the Code directly:
Sub zhoubao () Dim outapp As Object Dim outmail As Object Dim body As String Dim fname As String Set outapp = CreateObject ("Outlook. application ") 'Do not use the template' Set outmail = outapp. createItem (0) 'use the template Set outmail = outapp. createItemFromTemplate ("C: \ Users \ Administrator \ AppData \ Roaming \ Microsoft \ Templates \ weekly work summary and arrangement for April 9, 2014 (Zhou haiqing ). oft ") 'attachment fname =" D: \ E \ workspaces \ 3 _ company \ 2 _ report to company \ 1 _ weekly work report \ October week work summary and troubleshooting (.xlsx "'body B Ody = "<H3> <B> Hi, </B> </H3>" & _ "Please see attached! <Br> "& _" <br> <B> </B> "& _ GetSignature () On Error Resume Next With outmail. to = "xxx@chenzhimr.com" 'recipient. CC = "xx@czcinfo.com" 'CC. BCC = "" 'BCC. subject = "weekly work summary and arrangement for June 2014 (Zhou haiqing) --" & Now 'title. 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 \ Standard _cn.htm "Set f_SignatureObj = fso. openTextFile (SigPath, 1, False, 0) GetSignature = f_SignatureObj.ReadAllf_SignatureObj.CloseSet fso = NothingEnd Function
How to Use VBA in OutLook 2010: When you finish an email and click send, check whether there is any attachment
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 ("have you forgotten to paste the attachment! "& VbNewLine &" are you sure you want to send it? ",_
VbYesNo + vbDefaultButton2 + vbQuestion, "forgot to paste attachments ")
If cancelsend = vbNo Then Cancel = True
End If
End Sub
The automatic signature of the email sent in outlook, and will not appear when replying to the sender
Take outlook 2010 as an example. You can click "start"> "create email" in the upper left corner. Then you will see a "signature" button in the upper row and click the triangle, in the drop-down menu, select "signature" in the bottom line. A new dialog box is displayed, with "select default signature" on the right side. Select the corresponding signature except for the "new mail, don't forget to select the corresponding signature for "reply/forward ...... Have you read all of them? Do you know how to do this? Haha ...... It's not complicated. It's almost the same in 2007 cases. Ask again if you have any questions.