|
今日,小闻在办公室里看微信,忽然老佛爷出现眼前,阴沉讲一句“小闻,上班时间居然玩手机,跟我来,看过怎样处理你”。小闻灰溜溜地跟着后面。江少和斌哥互相对望一眼,老佛爷坐住办公椅讲“小闻,最近很自在?居然在上班时间玩手机!!!”。小闻默默不出声。老佛爷“既然你有时间玩,我帮你增加工作量”,指住笔记本讲,邮箱里未读邮件帮我回复他们,上午要完成任务!!!
小闻睁大眼睛 不出声,老佛爷抛了一句“完成不了,今个月绩效扣500元”!! 这!这真无天理
小闻马上处理 研究 终于以代码完成了
- '引用:Microseft Outlook *.0 Object Library
- Public j As Inspector
- Sub GetUnReadMailAutoReplyAll()
- '未读邮件自动回复
- '功能:根据发件人过滤,读取未读邮件,转发邮件
- Dim outApp As Outlook.Application
- Dim myNamespace As Namespace
- Dim myFolder As MAPIFolder
- Dim Folder As MAPIFolder
- Dim iMail As Outlook.MailItem
- Dim attFilename As String
- Dim myAttachment As Outlook.Attachment
- Dim mytmp As String
- Dim tmpa As String
- Application.DisplayAlerts = False
- Application.AskToUpdateLinks = False
- Application.ScreenUpdating = False
- '// Set outApp = GetObject("outlook.Application")
- '
- Set outApp = New Outlook.Application
- Set myNamespace = outApp.GetNamespace("MAPI")
- 'Set myFolder = MyNameSpace.PickFolder
- Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox) '//获得收件箱文件夹
- For Each iMail In myFolder.Items
- Call GetUnReadMail(iMail, myFolder.Name)
- Next iMai
- '//数据清零
- Application.DisplayAlerts = True
- Application.AskToUpdateLinks = True
- Application.ScreenUpdating = True
- Set iMail = Nothing
- Set myFolder = Nothing
- Set myNamespace = Nothing
- Set outApp = Nothing
- End Sub
- Sub GetUnReadMail(myMail As Outlook.MailItem, myFolderName As String)
- Dim attFilename As String
- Dim tmpa As String
- Dim mytmp As String
- '创建邮件体
- myForwardHTMLBody = CreateHTMLBody(2)
- If myMail.UnRead Then
- Set myAutoForwardMailItem = myMail.ReplyAll
- MsgBox myMail.SenderEmailAddress
- '设置收件人
- myAutoForwardMailItem.Recipients.Add "417149126@qq.com"
- rcvhtmlBody = myMail.HTMLBody
- rcvBody = myMail.Body
- mto = myMail.To
- '设置邮件体格式为outlook html格式
- myAutoForwardMailItem.BodyFormat = olFormatHTML
- '将原始邮件与新邮件连起来
- myAutoForwardMailItem.To = mto
- myAutoForwardMailItem.HTMLBody = myForwardHTMLBody & myAutoForwardMailItem.HTMLBody
- myAutoForwardMailItem.Send
- myMail.Save
- End If
- End Sub
- Public Function CreateHTMLBody(id As Integer) As String
- 'Creates a new e-mail item and modifies its properties
- Dim objHTMLBody As String
- '可以设置多个模板
- If id = 1 Then
- objHTMLBody = _
- "<font face = 微软雅黑 size = 3>" & _
- "感谢你的来信。我是<font color=red>机器人小星</font>,邮件我已代为阅读。" & _
- "<br/> <br/> " & _
- "来自小星的智能转发</font>"
- ElseIf id = 2 Then
- objHTMLBody = _
- "<table style = border-collapse:collapse <tbody>" & _
- "<tr><td style = border:1px solid #B0B0B0 colspan= 2>版本</td></tr>" & _
- "<tr><td style= border:1px solid #B0B0B0 >APP版本</td></tr>" & _
- "<tr><td style = border:1px solid #B0B0B0>SDK版本</td></tr>" & _
- "</tbody></table>" & _
- "" & _
- "<br/> <br/> " & _
- "来自小星的智能回复</font>"
- End If
- CreateHTMLBody = objHTMLBody
- End Function
复制代码
|
评分
-
查看全部评分
|