Log in

View Full Version : ขอ code ปรแกรมส่งเมลครับ



puanjai
21-11-2009, 08:57 PM
ใครพอมี code โปรแกรมส่งเมลบ้างครับ ที่ใช้กับโปรแกรม vb6 ครับ
จะทำโปรเจคส่งอาจารย์ครับ เพราะผมพื่งจะหัดเขียนโปรแกรมครับ
วานผู้รู้ช่วยผมด้วยนะครับ

wongpratan
21-11-2009, 09:33 PM
ใช้ outlook ในการส่งนะครับ

Public Sub SendOutlookMail(Subject As String, Recipient As _
String, Message As String)

On Error GoTo errorHandler
Dim oLapp As Object
Dim oItem As Object

Set oLapp = CreateObject("Outlook.application")
Set oItem = oLapp.createitem(0)
'
With oItem
.Subject = Subject
.To = Recipient
.body = Message
.Send
End With
'
Set oLapp = Nothing
Set oItem = Nothing
'

Exit Sub

errorHandler:
Set oLapp = Nothing
Set oItem = Nothing
Exit Sub
End Sub