Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-07-21
3
Medium Priority
?
1,670 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 200 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

Technology Partners: 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

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.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

704 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