Solved

Outlook Macro to send message: Need date insertion in Subject and Body

Posted on 2006-07-21
3
1,624 Views
Last Modified: 2012-08-13
Hello,
       I have an Outlook macro that I found on expert exchange that works great. It just sends an email when I click on it on the toolbar. I want to add the current date to the subject line and body of the macro. Here it is;

Sub Daily_Report()

Dim objMail As Outlook.MailItem
Set objMail = Application.CreateItem(olMailItem)

With objMail
  ' By default person will be added
  ' to the To area
  .Recipients.Add ("somebody@pvresorts.com")
  .Subject = "Daily Report for <date needed here>"
  ' Touching body makes it an RTF message
  .Body = "Somebody - The Daily Report for <date needed here> has been executed and printed. Thanks - PVsupport"
 
  ' Touching HTMLBody makes it HTML
  '.HTMLBody = "This is the body in HTML."
 
End With

' Send it
objMail.Send

' Display it
' objMail.Display

Set objMail = Nothing
End Sub


I have found various ways of getting the date on the forums but I am not sure of the syntax to work it into the macro
(I'm a Perl guy, not VB :)

Thanks,
S;
0
Comment
Question by:pvsupport
  • 2
3 Comments
 
LVL 2

Expert Comment

by:masoncooper
ID: 17156495
Change this line:
.Subject = "Daily Report for " & DATE
to
.Subject = "Daily Report for " & DATE

and

.Body = "Somebody - The Daily Report for <date needed here> has been executed and printed. Thanks - PVsupport"
to read
.Body = "Somebody - The Daily Report for " & DATE & " has been executed and printed. Thanks - PVsupport"
 
0
 
LVL 2

Accepted Solution

by:
masoncooper earned 50 total points
ID: 17156506
Err, the second line of my comment should read
  .Subject = "Daily Report for <date needed here>"
But I'm sure you get the point. :)
0
 

Author Comment

by:pvsupport
ID: 17159807
Thanks! perfect.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
count8 challlenge 13 86
powerN  challenge 3 47
Sorting in Excel with Group Headers if the Exist 2 68
topping1 challenge 7 51
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now