ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Running Outlook VB (https://www.excelbanter.com/excel-programming/275745-excel-running-outlook-vbulletin.html)

David Robinson[_2_]

Excel Running Outlook VB
 
How can I automate emails sent by triggering links within
Excel. I would like to send a standard email to various
recipients when a date condition is met (actually an
updated forecast). Do I need to buy and install VB6 or
would I be able to run a programme in Excel that drives
my Outlook?

David

Excel Running Outlook VB
 

Bon

Thank you. Could I run this from Excel vba?

-----Original Message-----
David,

VBA can easily send mail via Outlook. Here is some

example code

Dim objOutlook As Object
Dim objMailItem As Object
Dim objRecipient As Object
Dim objNameSpace As Object

Set objOutlook = CreateObject

("Outlook.Application")
Set objNameSpace = objOutlook.GetNameSpace

("MAPI")
objNameSpace.Logon , , True

Set objMailItem = objOutlook.CreateItem(0)
Set objRecipient =
objMailItem.Recipients.Add("bob.phillips@somewher e.com")
objRecipient.Type = 1 '1 = To, use 2 for cc
'keep repeating these

lines with
'your names, adding to the

collection.
objMailItem.Subject = "The extract has finished."
objMailItem.Body = "This is an automatic email

notification"
objMailItem.Attachments.Add

(Filename) 'you only need this if
you are sending attachments?
objMailItem.Send

If you want to include an attachment as shown, it has to

be a file not the
activeworkbook, so if you want to send the

activeworkbbok, save it firat,
and then send it as that file. You can

use 'ActiveWorkbook.FullName' to
access it without using hard-coded values.

You just will nedd to add the code to trigger the

mailing.

--

HTH

Bob Phillips

"David Robinson" wrote in

message
...
How can I automate emails sent by triggering links

within
Excel. I would like to send a standard email to various
recipients when a date condition is met (actually an
updated forecast). Do I need to buy and install VB6 or
would I be able to run a programme in Excel that drives
my Outlook?



.


David

Excel Running Outlook VB
 

Does vba refer to the excel visual basic?

-----Original Message-----
David,

VBA can easily send mail via Outlook. Here is some

example code

Dim objOutlook As Object
Dim objMailItem As Object
Dim objRecipient As Object
Dim objNameSpace As Object

Set objOutlook = CreateObject

("Outlook.Application")
Set objNameSpace = objOutlook.GetNameSpace

("MAPI")
objNameSpace.Logon , , True

Set objMailItem = objOutlook.CreateItem(0)
Set objRecipient =
objMailItem.Recipients.Add("bob.phillips@somewher e.com")
objRecipient.Type = 1 '1 = To, use 2 for cc
'keep repeating these

lines with
'your names, adding to the

collection.
objMailItem.Subject = "The extract has finished."
objMailItem.Body = "This is an automatic email

notification"
objMailItem.Attachments.Add

(Filename) 'you only need this if
you are sending attachments?
objMailItem.Send

If you want to include an attachment as shown, it has to

be a file not the
activeworkbook, so if you want to send the

activeworkbbok, save it firat,
and then send it as that file. You can

use 'ActiveWorkbook.FullName' to
access it without using hard-coded values.

You just will nedd to add the code to trigger the

mailing.

--

HTH

Bob Phillips

"David Robinson" wrote in

message
...
How can I automate emails sent by triggering links

within
Excel. I would like to send a standard email to various
recipients when a date condition is met (actually an
updated forecast). Do I need to buy and install VB6 or
would I be able to run a programme in Excel that drives
my Outlook?



.



All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com