Enhance this code

G

Guest

I just found the following code to automatically add the attachement and send
to a receipient. It works fine. But What I want is that one email address
should be in the "To" field and 3 other email address to be in the "Bcc"
field.

Also in the body of the mail, I need to add two constant line(Text) and with
my signature. Can someone enhance the below coding for this requirement.


Sub Foobar()
Dim oApp As Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oMail As Outlook.MailItem

Set oApp = CreateObject("Outlook.Application")
Set oNS = oApp.GetNameSpace("MAPI")
oNS.Logon

Set oMail = oApp.CreateItem(olMailItem)
With oMail
.Subject = "Cims data"
.Body = "Some body text"
.Attachments.Add "c:\myFolder\File1.xls"
.Attachments.Add "c:\myFolder\File2.xls"
.Recipients.Add "(e-mail address removed)"
.Recipients.ResolveAll
.Send
End With
End Sub
 
S

Sue Mosher [MVP-Outlook]

Set recip = oMail.Recipients.Add "(e-mail address removed)"
recip.Type = olBcc

Repeat as needed.

See http://www.outlookcode.com/codedetail.aspx?id=615 for a code sample to insert the user's default signature. Also note that if you call oMail.Display, the default signature will be added automatically. You can then prefix the Body property value with the text you want to add.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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