ส่งเมล์อัตโนมัติผ่าน Access to Outlook

เริ่มโดย Sakorn Onkhan, 18 ม.ค 20 , 10:05:09

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

Sakorn Onkhan

สวัสดีครับอาจารย์ทุกท่าน
ผมรบกวนเกี่ยวกับการส่งเมล์ครับ จากโค้ดด้านล่าง จะส่งเมล์ได้ทีละ email ครับ
ความต้องการอยากให้สามารถส่ง email ได้หลายๆ email ในครั้งเดียวครับ
โดยอยากให้อ้างอิงจากTable  email ที่มีอยู่ทั้งหมดครับ
รบกวนด้วยนะครับ
++++++++++++++++++++++++++++++++++++++++++++++++++++++

Private Sub Command1_Click()

    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Dim strPath As String
    Dim strFilter As String
    Dim strFile As String

    'strPath = "D:\test\"      'Edit to your path
    strPath = [txtPath]
    strFilter = [txtSupplier] & ".pdf"
    strFile = Dir(strPath & strFilter)

    If strFile <> "" Then

        Set appOutLook = CreateObject("Outlook.Application")
        Set MailOutLook = appOutLook.CreateItem(olMailItem)

        With MailOutLook
            .BodyFormat = olFormatRichText
            '.To = "[email protected]"
            .To = [txtEmail]
            ''.cc = ""
            ''.bcc = ""
            .Subject = "Test send Auto mail"
            .HTMLBody = "I would like to send you"
            .Attachments.Add (strPath & strFile)
            .Send
            '.Display    'Used during testing without sending (Comment out .Send if using this line)
        End With
    Else
        MsgBox "No file matching " & strPath & strFilter & " found." & vbCrLf & _
                "Processing terminated."
        Exit Sub    'This line only required if more code past End If
    End If

End Sub
  •  
    โพสต์นี้ได้รับคำขอบคุณจาก: jackychaan

PNR

แนวทางนะครับ

ใช้การสร้าง ฟอร์มแบบ Continuous Forms แล้วใช้ recordsetclone

แล้วใช้ การสร้าง Do while >  loop ให้ส่งได้ทุก Record ครับ
ให้ Loop จนครบทุก Record

Time to stop for me  :dizzy:
  •