请前面己下的,将下面代码中的红色部分注释掉,要不我的邮箱会给涨爆了,这行是我测试时用的邮箱.一楼附件己更新,(解决了一些问题) Sub mailto() Application.ScreenUpdating = False Dim objOL As Object Dim itmNewMail As Object Dim i%, j%, k%, x%, y% Dim strbt() As String, strsj() As String, strsum$ Set objOL = CreateObject("Outlook.Application") Sheets(1).Activate ActiveSheet.Range("a1").Select Set tk = ActiveCell.CurrentRegion k = tk.Columns.Count - 1 j = tk.Rows.Count - 1 ReDim strbt(k - 1) For i = 0 To k - 1 strbt(i) = Trim(Sheets(1).Range("a1").Offset(0, i).Value) Next i For x = 1 To j - 1 Set itmNewMail = objOL.CreateItem(olMailItem) itmNewMail.Subject = Month(Date) & "月份工资明细" itmNewMail.To = Trim(Sheets(3).Range("c" & x + 1)) ' itmNewMail.cc = "pengjianxiang@hun.picc.com.cn" For y = 0 To k - 1 ReDim strsj(y) strsj(y) = Sheets(1).Range("a1").Offset(x, y).Value strsum = strsum & strbt(y) & ": " & strsj(y) & vbCrLf Next y itmNewMail.body = strsum & vbNewLine & " 以上是你" & Month(Date) & "月份工资明细,如无误,请你于近日到财务部领取!" & vbNewLine & Space(60) & "财务部" & vbNewLine & Space(65) & Date itmNewMail.send strsum = "" Next x Set objOL = Nothing Set itmNewMail = Nothing Application.ScreenUpdating = True End Sub
|