Gửi mail tự động bằng Outlook, nhưng mail bị vướng trong Outbox phải làm sao?

Liên hệ QC

Hoàng Trọng Nghĩa

Chuyên gia GPE
Thành viên BQT
Moderator
Tham gia
17/8/08
Bài viết
8,590
Được thích
16,653
Giới tính
Nam
Tôi tập tành gửi mail bằng VBA, code chạy OK, nhưng mail không được gửi đi mà vướng lại tại Outbox, xin cho biết cách khắc phục. Cám ơn.

1709288862944.png
 
Không đâu, gửi 2 mail và 2 địa chỉ khác nhau thôi. Vấn đề không nằm ở code mà ở Outlook, nó "nhốt" mấy thằng em ở lại trong Outbox.
Bác kiểm tra xem có mở IMAP trên tài khoản Gmail chưa? Bảo mật 2 lớp?
Trong Outlook:
- Các thông số incoming Server: imap.gmail.com; outgoing server: smtp.gmail.com
- Các Port cho nó....
Nói chung là thử các tham số cài đặt.
 
Bác kiểm tra xem có mở IMAP trên tài khoản Gmail chưa? Bảo mật 2 lớp?
Trong Outlook:
- Các thông số incoming Server: imap.gmail.com; outgoing server: smtp.gmail.com
- Các Port cho nó....
Nói chung là thử các tham số cài đặt.
Mình xài Office 365, không biết nó có vấn đề gì không, mấy cái anh nói mình cũng không rành lắm.

Mã:
Sub SendEmail(S_UserName As String, S_EmailID As String)

    'Declaring variables as object type  to refer Outlook Application & Mail Item

    Dim OutApp As Object ' Outlook Application
    Dim OutMail As Object  'Outlook Mail Item
    Dim sImgName As String
    
    'Set the reference of Outlook Application
    
    Set OutApp = CreateObject("Outlook.Application")
    
    'Set the reference  of Mail  Item
    
    Set OutMail = OutApp.CreateItem(0)
    
    On Error Resume Next
    
    With OutMail
    
        .To = S_EmailID
        .From = ""
        .CC = "Info@TheDataLabs.Org"
        .BCC = ""
        .Attachments.Add ThisWorkbook.Path & "\Service List.xlsx"
        
        'Code to embed  the image in mail body without using the original image source.
        
        .Attachments.Add ThisWorkbook.Path & "\TheDataLabs.jpg"
         sImgName = "TheDataLabs.jpg"
        .Subject = "Thank you for enquiring about our services!"
        .HTMLBody = "<HTML><Body><P>Dear " & S_UserName & ",<BR><BR>Thank you for enquiring about Dashboard and Automation services! Our team will review the requirements and get back to you ASAP.<BR><BR>In meantime, you can visit our website <a href=""www.thedatalabs.org"">www.thedatalabs.org</a> to see the testimonials and feedback from other clients. Also, you can download and use some dashboard and automation templates without any cost. <BR><BR>You can refer to the attached Excel file to see the list of services we are providing.<BR><BR><a href=""www.thedatalabs.org""><img src='cid:" & sImgName & "'" & " ></a><BR> <BR>Regards,<BR>TheDataLabs Team<BR>info@thedatalabs.org </P></Body></HTML>"
        .Display
        .Send
    End With
    
    Set OutMail = Nothing
    Set OutApp = Nothing
      
End Sub

Code của nó cũng không vấn đề gì phải không?
 
Đây là source mà tôi sưu tầm trên mạng, ai rành về cái này hướng dẫn tôi nhé.
 

File đính kèm

  • Email.zip
    72.1 KB · Đọc: 4
Anh chỉnh code thử gửi 1 mail, trong mail không có file đính kèm, nội dung body mail chỉ gửi vài ký tự "abc" thôi. Xem tình hình thế nào.
Khó hiểu quá, hôm qua gửi các kiểu cả ngày đống mail chỉ nằm trong outbox, hôm nay thử gửi lại, toàn bộ đi hết??????????
 
Web KT
Back
Top Bottom