How I auto send e-mail from excel with predefined subject and tex

G

Guest

i'm trying autosend e-mails from excel, but need to every time outoolk opens
already shows subject and message body. The hyperlink function is part of a
formula that provides acees to outlook
 
G

Guest

Modify the Ranges and Values to suit your situation.

Dim OutApp As Outlook.Application
ThisWorkbook.Activate
Dim OutMail As Outlook.MailItem
Dim strbody As String

A = Sheets("Macros").Range("C16").Value
B = Sheets("Macros").Range("C18").Value
C = Sheets("Macros").Range("A1").Value

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
strbody = "Attached is the " & C & " CSFB Activity Report." & vbNewLine
& vbNewLine & _
"Please let me know if you have any questions."
Enclosures = wbk1

IncludeAttachments = True
With OutMail
.To = A
.CC = B
.BCC = ""
.Subject = "CSFB Activity Comparison"
.Body = strbody
.Attachments.Add Workbooks(wbk1).FullName
' .Attachments.Add Workbooks(wbk2).FullName
.Display

End With

Set OutMail = Nothing
Set OutApp = Nothing
 
G

Guest

I too would like to get a result from this; however i get a compile error:
user- defined type not defined.

Any suggestions?
 
D

Dave Peterson

Select your project in the VBE
tools|References|
look for Microsoft Outlook xx.x Object Library

and check it.
 
G

Guest

Thank you, this is now working a treat.

Ideally i would like to start the body of the email with a line from the
workbook such as

Dear "name"

and then finish off with a standard signature from Outlook,

I could add the standard signature into the code but i don't get the nice
html effects i have in my signature

Any suggestions?
 

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