منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
ارسال بريد الكتروني باستخدام Ole - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : الأقسام التعليمية - المنتدى القديم (http://vb4arb.com/vb/forumdisplay.php?fid=90)
+--- قسم : مكتبة أكواد المنتدى (http://vb4arb.com/vb/forumdisplay.php?fid=111)
+---- قسم : مكتبة أكواد الفيجوال بيسك 6 (http://vb4arb.com/vb/forumdisplay.php?fid=116)
+---- الموضوع : ارسال بريد الكتروني باستخدام Ole (/showthread.php?tid=5810)



ارسال بريد الكتروني باستخدام Ole - RaggiTech - 17-10-12

كاتب الموضوع : AhmedEssawy


كود :
Private Sub Send_Email(Subject As String, MessageText As String, RecipientName As String)
Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object

' Create the Session Object
Set objSession = CreateObject("mapi.session")

' Logon using the session object
' Specify a valid profile name if you want to
' Avoid the logon dialog box
objSession.Logon profileName:="MS Exchange Settings"

' Add a new message object to the OutBox
Set objMessage = objSession.Outbox.Messages.Add

' Set the properties of the message object
objMessage.subject = Subject
objMessage.Text = MessageText

'Add a recipient object to the objMessage.Recipients collection
Set objRecipient = objMessage.Recipients.Add

'Set the properties of the recipient object
objRecipient.Name = RecipientName
objRecipient.Type = mapiTo
objRecipient.Resolve
'Send the message
objMessage.Send showDialog := False
MsgBox "Message sent successfully!"
' Logoff using the session object
objSession.Logoff
End Sub