Private Sub CommandButton1_Click()
Dim Flds
Dim iMsg As New CDO.Message
Dim iConf As New CDO.Configuration
Set Flds = iConf.Fields
schema = "http://schemas.microsoft.com/cdo/configuration/"
Flds.Item(schema & "sendusing") = cdoSendUsingPort
Flds.Item(schema & "smtpserver") = "smtp.gmail.com"
Flds.Item(schema & "smtpserverport") = 25
Flds.Item(schema & "smtpauthenticate") = 1
Flds.Item(schema & "sendusername") = "bcdf573@gmail.com" 'Dia chi that
Flds.Item(schema & "sendpassword") = "************" 'Pass that
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
With iMsg
.To = "po_pikachu@ymail.com" 'tuy y
.CC = ""
.BCC = ""
.AddAttachment ("C:\IP_Address.txt") 'Dia chi file phai ton tai
.from = "testmail3" & "<" & "Blanche_Princess@yahoo.com" & ">" 'tuy y
.Subject = "Subject3" 'tuy y
.HTMLBody = "Hello, This is a Test Mail & File" 'tuy y
Set .Configuration = iConf
.Send
End With
MsgBox "Ðã Xong"
End Sub
Bạn ơi! ví dụ mình có 1 list khoảng 100 người muốn gửi mỗi người 1 file attach thì mình điều chỉnh code như thế nào? Bạn gíup mình với nhé!Code ở trên phức tạp quá. Lỗi lung tung cả lên rùi. Ai đó muốn nâng cấp đầy đủ thì xem nó sau đi. Giờ quay về cái đơn giản nha!
Đầu tiên cần phải kích hoạt Microsoft CDO for Windows 2000 Library mới chạy được nha (Bạn vào cửa sổ VBA -> chọn Tools -> Reference.. -> kéo thanh trược tìm dòng Microsoft CDO for Windows 2000 Library -> Click vào -> OK).
Ứng dụng thì nhiều lắm.PHP:Private Sub CommandButton1_Click() Dim Flds Dim iMsg As New CDO.Message Dim iConf As New CDO.Configuration Set Flds = iConf.Fields schema = "http://schemas.microsoft.com/cdo/configuration/" Flds.Item(schema & "sendusing") = cdoSendUsingPort Flds.Item(schema & "smtpserver") = "smtp.gmail.com" Flds.Item(schema & "smtpserverport") = 25 Flds.Item(schema & "smtpauthenticate") = 1 Flds.Item(schema & "sendusername") = "bcdf573@gmail.com" 'Dia chi that Flds.Item(schema & "sendpassword") = "************" 'Pass that Flds.Item(schema & "smtpusessl") = 1 Flds.Update With iMsg .To = "po_pikachu@ymail.com" 'tuy y .CC = "" .BCC = "" .AddAttachment ("C:\IP_Address.txt") 'Dia chi file phai ton tai .from = "testmail3" & "<" & "Blanche_Princess@yahoo.com" & ">" 'tuy y .Subject = "Subject3" 'tuy y .HTMLBody = "Hello, This is a Test Mail & File" 'tuy y Set .Configuration = iConf .Send End With MsgBox "Ðã Xong" End Sub
Có người đã từng hỏi. "Muốn gửi thư mời họp của toàn thể công ty thì sao?". Vậy là văn phòng ngồi cả ngày lẫn đêm cứ copy/paste mãi. Giờ thì dùng như vầy cho tiện. Phần nội dung hay file đính kèm thì cũng có thể thêm dễ dàng và không báo lỗi Outlook nữa.
Còn giới hạn thư gửi bao nhiêu 1 ngày thì cho em xin kiếu. Hộp thư em đầy mât rùi. hihi
Mà Cấm mọi ng SPAM thư em đó nha!
Thân.
Code ở trên phức tạp quá. Lỗi lung tung cả lên rùi. Ai đó muốn nâng cấp đầy đủ thì xem nó sau đi. Giờ quay về cái đơn giản nha!
Đầu tiên cần phải kích hoạt Microsoft CDO for Windows 2000 Library mới chạy được nha (Bạn vào cửa sổ VBA -> chọn Tools -> Reference.. -> kéo thanh trược tìm dòng Microsoft CDO for Windows 2000 Library -> Click vào -> OK).
PHP:Private Sub CommandButton1_Click() .... With iMsg .To = "po_pikachu@ymail.com" 'tuy y .CC = "" .BCC = "" .AddAttachment ("C:\IP_Address.txt") 'Dia chi file phai ton tai .... End Sub