ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

§Q¥Îvbaµomailªº°ÝÃD

§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

        ÀR«ä¦Û¦b : ¤@¥y·Å·xªº¸Ü¡A´N¹³©¹§O¤H¨­¤WÅx­»¤ô¡A¦Û¤v·|ªg¨ì¨â¤Tºw¡C
ªð¦^¦Cªí ¤W¤@¥DÃD