- ©«¤l
- 20
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 61
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- 2003
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW®ç¶é
- µù¥U®É¶¡
- 2010-9-1
- ³Ì«áµn¿ý
- 2019-4-26
|
§Q¥Îvbaµomailªº°ÝÃD
¦U¦ì¤j¤j¡A³Ìªñ§Ú¼g¤F¤@Ӧ۰ʵomailªºµ{¦¡¡A¦ý¹J¨ì¤F2Ó°ÝÃD¡A¤£ª¾¹D¦³¨S¦³¤H¥i¥HÀ°§Ú¸Ñ¨M¤@¤U¡AÁÂÁ¡C
¥H¤U¬O§Úªºµ{¦¡½X¡G
1.³oÓµ{¦¡½X¦³®ÉÔ·|±H¤£¥X¥h¡A§Ú´ú¸Õ2~3Ó¤H®É³£¬O¥¿±`ªº¡A¦ý¤H¼Æ¶W¹L20Ó¤H¥H¤W´N®e©öµo¥Í±H¤£¥X¥h
2.outlook 2010®É·|¥X²{¦w¥þ©Ê°ÝÃD¡A¤]®e©ö³y¦¨mail±H¤£¥X¥h
Sub Auto_SendMail()
On Error Resume Next
Dim objOutlook As Object
Dim objMail As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(olMailItem)
Sheets("Setting Sheet").Select
Email = ""
Email_cc = ""
'½T»{¦¬¥ó¤H»P°Æ¥ó¤Hû¦W³æ¬O§_¬OªÅªº
If WorksheetFunction.CountA(Columns(18)) < WorksheetFunction.CountA(Columns(19)) Then
MsgBox "§Û°e¤H数¤£¥i¤j¤_¥¿±`¦¬¥óªÌ¤H数¡A请«·sÚÌ认¡A谢谢¡C"
Set objMail = Nothing
Set objOutlook = Nothing
Exit Sub
Else
If WorksheetFunction.CountA(Columns(18)) <= 1 Then
MsgBox "¥¿±`¦¬¥óªÌ¤H数¤£±o为ªÅ¡A请«·sÚÌ认¡A谢谢¡C"
Set objMail = Nothing
Set objOutlook = Nothing
Exit Sub
End If
End If
For r = 2 To WorksheetFunction.CountA(Columns(18))
Email = Sheets("Setting Sheet").Cells(r, 18) & ";" & Email
If Sheets("Setting Sheet").Cells(r, 19) <> "" Then
Email_cc = Sheets("Setting Sheet").Cells(r, 19) & ";" & Email_cc
End If
Next r
' Compose the message
Msg = ""
Msg = Msg & "Dear all," & vbCrLf & vbCrLf
Msg = Msg & "ªþ¥óExcel¬O´ú¸Õ Data - " & Format(Now(), "YYYY/MM/DD") & " " & Format(Now(), "HH:00(AM/PM)") & "数Õu¡C" & vbCrLf & vbCrLf
Msg = Msg & "数Õu¬O从" & Format(Now() - 2, "YYYY/MM/DD") & " 00:00 ¦Ü " & Format(Now(), "YYYY/MM/DD") & " " & Format(Now(), "HH:00(AM/PM)") & "¡]测试时间点¡^¡C" & vbCrLf & vbCrLf
Msg = Msg & "Best Regards!"
' Message subject
Subj = "test mail!!"
With objMail
.To = Email
.CC = Email_cc
.Subject = Subj
.Body = Msg
.Attachments.Add Save_File_Path & "AAAA_" & Format(Now(), "YYYYMMDD") & "_" & Format(Now(), "HH(AM/PM)") & ".xlsm"
.Display
.Send
End With
Set objMail = Nothing
Set objOutlook = Nothing
End Sub |
|