Solved

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

Posted on 2006-07-21
3
1,641 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now