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


0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

18 ม.ค. 63 , 10:05:09
อ่าน 955 ครั้ง

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 = "sakornonk@gmail.com"
            .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

20 ม.ค. 63 , 13:07:57
ตอบกลับ #1

PNR

: ส่งเมล์อัตโนมัติผ่าน Access to Outlook
« ตอบกลับ #1 เมื่อ: 20 ม.ค. 63 , 13:07:57 »
แนวทางนะครับ

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

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

Time to stop for me  :dizzy:
 


บอร์ดเรียนรู้ Access สำหรับคนไทย


 

Sitemap 1 2 3 4 5