Outlook VBA

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

Does anyone know of any good sites out there which could show me how to go about creating & sending an email to a given recipient each day? I need to attach a csv file to the mail (first checking that the file date on said file is today's date). I have never used Outlook VBA before,and frankly wouldn't know where to start!

Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi Richard, try www.helenfeddema.com

She does a lot of inter-application stuff, quite a lot of it with Access and / or Outlook. The 2 main resource pages are Access Archon (almost entirely Access, some inter-app stuff), and Code Samples (pretty varied).

Also, I don't know about VBA but she may have some: www.slipstick.com is run by an Outlook / Exchange MVP.

And a Google search brought up... http://www.outlookcode.com/d/vb.htm

Denis
 
Upvote 0
Hi Denis

Decided to give it a go myself and came up with the following (may not be wholly robust/competently coded, but does what I want):

Code:
Sub CreateAndSend()
Dim fso, oFDT, myOlApp,myitem,myAttachments
Set fso = CreateObject("Scripting.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:\MyFile.csv", _
    olByValue, 1
myitem.To = "Whomever@Wherever.com"
myitem.Subject = "My Subject Line"
myitem.Display
myitem.Send
End Sub

Thanks for the reply though - my respect for Helen Feddema is growing all the time!
 
Upvote 0

Forum statistics

Threads
1,225,286
Messages
6,184,069
Members
453,208
Latest member
Palo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top