Solved

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

Posted on 2006-07-21
3
1,656 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This is about my first experience with programming Arduino.
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 …

751 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