Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook - General Queries (http://www.outlookbanter.com/outlook-general-queries/)
-   -   Automated mail creation & sending (http://www.outlookbanter.com/outlook-general-queries/40787-automated-mail-creation-sending.html)

RichardSchollar February 14th 07 09:41 AM

Automated mail creation & sending
 
Hello everyone

I create a report from a legacy system in csv format every day, and
once it has been produced I need to attach it to an email and send
this email out to one recipient (the same one every day). The subject
line is also the same every day, and the report is saved down to my C
drive.

How can I automate the process? Not running the report, but picking it
up from its specified location - preferably confirming first that the
file date is today's date (the date is NOT incorporated within the
file name) - and attaching it to an email to the recipient and with
the standard header?

I am conversant with Excel VBA but have never used Outlook VBA before.

Any help appreciated.

Best regards

Richard Schollar


RichardSchollar February 14th 07 12:15 PM

Automated mail creation & sending
 
I'm sure the following will make more competent coders cringe, but it
does what I need:

Sub CreateAndSend()
Dim fso, oFDT, myOlApp,myitem,myAttachments
Set fso = CreateObject("Scripting.FileSystemObject")
'Set fso = New FileSystemObject
Set oFDT = fso.GetFile("C:\MyFile.csv")
If Format(oFDT.DateLastModified, "ddmmyyyy") Format(Date,
"ddmmyyyy") Then
MsgBox "MyFile.csv does not carry today's Date Stamp": Exit Sub
End If

Set myOlApp = CreateObject("Outlook.Application")
Set myitem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myitem.Attachments
myAttachments.Add "C:\AXAFIL.csv", _
olByValue, 1
myitem.To = "
myitem.Subject = "My Subject Line"
myitem.Display
myitem.Send
End Sub



On 14 Feb, 09:41, "RichardSchollar"
wrote:
Hello everyone

I create a report from a legacy system in csv format every day, and
once it has been produced I need to attach it to an email and send
this email out to one recipient (the same one every day). The subject
line is also the same every day, and the report is saved down to my C
drive.

How can I automate the process? Not running the report, but picking it
up from its specified location - preferably confirming first that the
file date is today's date (the date is NOT incorporated within the
file name) - and attaching it to an email to the recipient and with
the standard header?

I am conversant with Excel VBA but have never used Outlook VBA before.

Any help appreciated.

Best regards

Richard Schollar





All times are GMT +1. The time now is 05:30 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com