Solved

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

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Simple Linear Regression
Six Sigma Control Plans

623 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