Sneding email thru VBA (using Exchange)

B

Bigfoot17

I have seen references to using VBA in Excel to send sheets/books to
recipients. Usually questions are directed to Ron deBruin's site
(http://www.rondebruin.nl/cdo.htm). However I have two issues.

[1] I am sending using an exchange server and the references are for using
SMTP. How is using an Exchange Server different?

[2] I'd like to send the file as an attachment but could not find info on
how to accomplish this. Should I need go to the Outlook forum? (I want to
send the files from within my Excel VBA programming).
 
R

Ron de Bruin

Hi Bigfoot17

1: ask your IT department for the server name

2: On the CDO page there is a download with examples
 
C

codex

Hi,
add references : microsoft outlook xxxx object library

if you want to send your shet mail body use this code :

Sub mailsend()
' Requires reference to Microsoft Outlook
Dim ws As Worksheet, env As MsoEnvelope, mi As MailItem
' Get the active worksheet.
Set ws = ActiveSheet
' Save the workbook before mailing as attachment.
ws.Parent.Save
' Show email header.
ws.Parent.EnvelopeVisible = True
' Get the MsoEnvelope object
Set env = ws.MailEnvelope
' Set the email header fields.
' env.Introduction = "Please revew attached file."
' Get the MailItem object.
Set mi = env.Item
' Clear the MailItem properties.
ClearMessage mi
' Set MailItem properties.
mi.Importance = olImportanceHigh
' Set MailItem properties ImportanceHigh.
mi.SentOnBehalfOfName = "(e-mail address removed)"
' Set MailItem sender if use different sender.
mi.To = "(e-mail address removed);[email protected]"
mi.CC = "(e-mail address removed)"
mi.Subject = "Subject text in here"
' Attach this workbook.
mi.Attachments.Add "d:\sample.pdf" ''ThisWorkbook.FullName
' Uncomment this to send automatically.
mi.Send
End Sub

and if you want to send your any document, use :

mi.Attachments.Add
 

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