VB Code:
'In your project go to References and click Microsoft Outlook 8.0/11.0 Object Library. ' make sure a reference to the Outlook object is set ' place the following code in a command button click event Private Sub cmdSendMail_Click() Dim objOutlook As Outlook.Application Dim objMailItem As Outlook.MailItem Set objOutlook = New Outlook.Application Set objMailItem = objOutlook.CreateItem(olMailItem) With objMailItem.To = "ToAddress" 'recipient's address .Subject = "subject" 'subject box content .Body = "email message" ' message goes here .Attachment = "c:\path\file.txt" ' attach any files here .Send End With Set objMailItem = Nothing Set objOutlook = Nothing End Sub




Reply With Quote