Function SendMailFromOutlook(sMailto,sMailCC,sSubject,SBody,sAttachment,MyName)
set oMailobj=CreateObject("Outlook.Application")
set oSendmail=oMailobj.CreateItem(0)
oSendmail.To=sMailto
oSendmail.Subject=sSubject
oSendmail.CC=sMailCC
oSendmail.HTMLBody = sBody & "<br><br><b> -Regards</b><br>" & MyName
If (sAttachment <> "") Then
oSendmail.Attachments.Add(sAttachment)
End If
oSendmail.Send
set oSendmail=Nothing
set oMailobj=Nothing
End Function
Example: Call the above Function with the values
(1)
sMailto="rohan@gmail.com;sameep@yahoo.com"
sMailCC="richa@gmai.com;"
sSubject="Party at home"
sBody=" be there at 10"
sAttachment="c:\partyimage.jpeg"
MyName="Mitesh"
Call SendMailFromOutlook(sMailto,sMailCC,sSubject,SBody,sAttachment,MyName)
(2) Or you can call this function by using inline values
Call SendMailFromOutlook("mitesh@gmai.com","","mysubject","how are you","","Rohan")
OUTPUT
=======
Mail will be sent from Outlook in your machine
No comments:
Post a Comment