Outlook 2007 Macro

jslipher

New Member
Joined
Jul 27, 2011
Messages
22
Hello everyone! Thank you so much for helping me out with my problem. This forum has been a life saver! Here is what I need to do:

I would like a macro that would send an email to a distribution group I have called 'Matchbook' with a subject stating 'Matchbooks 10.19' (in other words Matchbook and today's date) and then in the body of the email, all there needs to be is a hyperlink to a network folder. The network folder path is G:\Pm\Matchbooks\Most Recent. I can change the Most Recent folder name to Most_Recent if that helps for code. Also, I would like the hyperlink to be displayed as 'Today's Matchbook Files'. Thank you so much for all of your help!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I have created this from Excel, to test it place it in a workbook and then use Alt + F11 and then Insert a Module from the Insert Menu.
Sub MailURL()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<HTML><BODY>"
strbody = strbody & "<A href=http://G:\Pm\Matchbooks\Most Recent>'Today's Matchbook Files'</A>"
strbody = strbody & "</BODY></HTML>"
On Error Resume Next
With OutMail
.To = "Matchbook"
.Subject = "Matchbooks " & Format(Date, "dd mmm yyyy")
.HTMLBody = strbody
.display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
Upvote 0
Thanks for the help! I did run into a couple problems though. The date in the subject did not work, so I just removed it from the code because it is not that important. The distribution list named Matchbook did not work becuase it just inserted the word and not the distribution list. And when I clicked on the hyperlink, it tried taking me somewhere on the internet instead of opening up a folder that is mapped to the address on our network drive.
 
Upvote 0
Try this then. The Distribution name would work, what happens if you click in the To area? The date is just formatted and shows.

Sub MailURL()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "Matchbook"
.Subject = "Matchbooks " & Format(Date, "dd mmm yyyy")

.Body = "file://M:\Projects"
.display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
Upvote 0
Happy to help. Pleased to read you have a working solution.

Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,225,606
Messages
6,185,956
Members
453,333
Latest member
BioCoder84

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