Activeworkbook.sendmail

J

Jamie

Im trying to use the activeworkbook.sendmail function in a
macro, but am having trying sending to multiple
recipients. How do you do this? Also, is there any way
in which you can add text to the email rather than just
the subject?

Many thanks
Jamie
 
C

Cole

try this see if it is what you want but you need to add Microsoft Outlook
object library

Option Explicit
Function SendMail()

If MsgBox("Data about to send out! Continue?", vbOKCancel) = 1 Then

Dim oOutl As New Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oMail As Outlook.MailItem

Set oNS = oOutl.GetNamespace("MAPI")


oNS.Logon "MS Exchange Settings", "login", False, False ' requests
user name and password

Set oMail = oOutl.CreateItem(olMailItem)

On Error Resume Next
With oMail
.Subject = "mySubject"
'.Recipients.Add "(e-mail address removed)"
.Recipients.Add "(e-mail address removed)"
.Body = "What I want to say?"
.Attachments.Add myPath & "myFile"
.Send
End With


oNS.Logoff
Set oNS = Nothing

'Application.Quit acSaveYes
Else
'Application.Quit acSaveYes
End If


End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top