Solved: Excel 2007 Automatic E-mail

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

computerman29642

Thread Starter
Joined
Dec 4, 2007
Messages
2,895
Is there a way to have Excel 2007 to automatically send a document by e-mail (not an XLS file)?
 
Joined
Jul 1, 2005
Messages
8,546
The below is a cut-down of this code.

Note that (i) client is Outlook (ii) early binding requires setting a reference to Outlook in Excel's VBE before use.

HTH

Sub SendWithAtt()

Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim CurrFile As String

Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)

With olMail
.To = "[email protected]"
.Subject = "This is the subject"
.Attachments.Add "C:\Documents and Settings\Andy\My Documents\test.doc"
.Display
.Send
End With

Set olMail = Nothing
Set olApp = Nothing

End Sub
 

computerman29642

Thread Starter
Joined
Dec 4, 2007
Messages
2,895
Bomb, the code looks great.

Here is something wierd. I tested the code by sending an e-mail to myself. When I look in th esent folder, I can see the e-mail was sent. However, I never received the e-mail.
 

computerman29642

Thread Starter
Joined
Dec 4, 2007
Messages
2,895
Nevermind. The first test did not work, but I have been able to get two other test e-mails to work.

Thank you very much, Bomb. :)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top