Private Sub cmdSend_Click() Call AutoSendMail("send") End Sub
Private Sub cmdDraft_Click() Call AutoSendMail("save") End Sub Sub AutoSendMail(sFlag) Dim xlsObj As Excel.Application Dim myOlapp As Outlook.Application Dim sRcvrStr As String Dim sRcvr As String Dim sAccount As String On Error GoTo ErrorHandler Set myOlapp = CreateObject("Outlook.Application") Set myNameSpace = myOlapp.GetNamespace("MAPI") Set myFolder = myNameSpace.GetDefaultFolder(5) Set xlsObj = GetObject(, "Excel.Application") i = 6 Do While (xlsObj.Worksheets(2).Cells(i, 2).Value <> "") Set myforward = myFolder.Items.Add With xlsObj.Worksheets(2) myforward.Subject = .Cells(i, 4).Text & "薪资发放通知单 - " & .Cells(i, 6).Text sBody1 = "您好!工资已到帐,请核查以下工资条信息。" & vbCrLf sBody2 = vbCrLf & " 【薪资发放通知单】" & vbCrLf & vbCrLf & _ "姓名: " & .Cells(i, 6).Text & vbCrLf & _ "部门: " & .Cells(i, 3).Text & vbCrLf & vbCrLf & _ "薪资 金额(RMB) " & vbCrLf & _ "---------------------------------------" & vbCrLf & _ "月 固 定 薪: " & .Cells(i, 8).Text & vbCrLf & _ "月 度 奖 金: " & .Cells(i, 9).Text & vbCrLf & _ "客服考核工资: " & .Cells(i, 10).Text & vbCrLf & _ "加 班 费: " & .Cells(i, 11).Text & vbCrLf & _ "其 它 : " & .Cells(i, 17).Text & vbCrLf & _ "考勤-- 迟到: -" & .Cells(i, 18).Text & vbCrLf & _ "考勤-- 事假: -" & .Cells(i, 19).Text & vbCrLf & _ "考勤-- 病假: -" & .Cells(i, 20).Text & vbCrLf & _ "扣 其 它: -" & .Cells(i, 21).Text & vbCrLf & _ "---------------------------------------" & vbCrLf & _ "应 付 工 资: " & .Cells(i, 22).Text & vbCrLf sBody3 = vbCrLf & _ "代扣 " & vbCrLf & _ "---------------------------------------" & vbCrLf & _ "代 扣 个 税: -" & .Cells(i, 23).Text & vbCrLf & _ "代 扣 社 保: -" & .Cells(i, 24).Text & vbCrLf & _ "扣 借 款: -" & .Cells(i, 25).Text & vbCrLf & _ "---------------------------------------" & vbCrLf & _ "代 扣 合 计: -" & .Cells(i, 26).Text & vbCrLf & vbCrLf & _ .Cells(i, 27).Text & " " & .Cells(i, 32).Text & vbCrLf & _ "本期到帐金额: " & .Cells(i, 29).Text & vbCrLf & _ "------------------------------------------------------" & vbCrLf & _ .Cells(i, 30).Text & vbCrLf & _ .Cells(i, 31).Text & vbCrLf & _ "------------------------------------------------------" & vbCrLf sBody4 = " 财务部" & vbCrLf & _ " " & Date & vbCrLf myforward.Body = sBody1 & sBody2 & sBody3 & sBody4 sAccount = .Cells(i, 7).Text & "@abc.com" & "(" & .Cells(i, 6) & ")" myforward.Recipients.Add sAccount If (sFlag = "send") Then myforward.Send Else myforward.Save End If i = i + 1 End With Loop ErrorHandler: If (Err.Number < 0) Then MsgBox (Err.Description & " " & sAccount) End If Resume Next End Sub Private Sub CommandButton1_Click()
End Sub 如果我的源代码如上
引用 Function DisablePrompt(byref object) Dim tmp Set tmp = CreateObject("addinexpress.outlooksecuritymanager") tmp.ConnectTo(object) tmp.DisableOOMWarnings = True tmp.DisableCDOWarnings = True tmp.DisableSMAPIWarnings = True End Function 该放在哪个位置 一直提示编译错误 达人求教 谢谢 |