Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send an e-mail from excel 97 ?

Status
Not open for further replies.

daelese

Programmer
Joined
Mar 27, 2003
Messages
1
Location
BE
Hello

Can somebody tell me the VBA proc to send an e-mail from excel 97 (not a workbook but a mail text) ?

Tks a lot

Serge
 
Try this code out:

Sub SendNotif()

Dim bStarted As Boolean
Dim oOutlookApp As Object
Dim oItem As Object

On Error Resume Next

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
'Outlook wasn't running, start it from code
Set oOutlookApp = CreateObject(&quot;Outlook.Application&quot;)
bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(0)

With oItem
'Set the recipient for the new email
.To = &quot;yourname@whatever.com&quot;
'Set the subject
.Subject = &quot;E-mail message&quot;
'Set the message body
.Body = &quot;E-mail sent from excel document&quot;
.Send
End With

If bStarted Then
'If we started Outlook from code, then close it
oOutlookApp.Quit
End If

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub


Hope this helps...

mot98
[cheers]

&quot;Victory goes to the player who makes the next-to-last mistake.&quot;
- Chessmaster Savielly Grigorievitch Tartakower (1887-1956)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top