e-mail Question !!

camador

New member
Local time
Yesterday, 18:41
Joined
Oct 2, 2003
Messages
5
Hi there, i've recently asked for an application that be able to send an e-mail (not a single record but a html page or anything) to a single address (stored in a table), I know that i can send messages but not how to do this with an external file.

All suggestions are welcome, thanks.
 
Try this Sub


Sub SendEMail(strRecipient As String, strSubject As String, strBody As String, optional strAttachment As String)

Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
Dim intAtt As Integer
On Error Resume Next

Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To = strRecipient
.Subject = strSubject
.body = strBody
if strAttachments then
.Attachments.Add Source:=strAttachment Type:=olByValue, _
DisplayName:="Attachment"
end if
.Send
End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub
 

Users who are viewing this thread

Back
Top Bottom