Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Custom Subject in Email (XP)

    Below is some code I'm using to send out a workbook on a daily basis.

    I'd like to be able to "customize" the subject by adding the current date.

    Is it possible to do that?

    Thanks


    Sub Email()
    'The below section sends the email automatically.
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    With OutMail
    .To = "address@email.com"
    .CC = ""
    .BCC = "
    .Subject = "Report"

    .Attachments.Add ActiveWorkbook.FullName
    .Body = "This is an auto-generated email " & vbCrLf & _
    "" & vbCrLf & _
    ""
    .ReadReceiptRequested = True

    .SEnd 'or use .Display
    End With
    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Custom Subject in Email (XP)

    .Subject = "Report for " & Format(Date, "mmmm dd, yyyy")

    (The e-mail header already contains the date, so it's kind of redundant.)
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom Subject in Email (XP)

    I've used this macro for quite a while and it's been great.
    I've had a request to change the subject a bit.
    Currently it lists "Report for" and then the current date. Is there a way for it to automatically populate the next day's date?
    Also, is there a way to add additional text in the subject after the date insertion?

    Thanks for all the help that is provided here.

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Custom Subject in Email (XP)

    Something like:

    .Subject = "Report for " & Format(Date+1, "mmmm dd, yyyy") & " Additional Text"

    Steve

  5. #5
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom Subject in Email (XP)

    Thank you very much.

    I think I had some spaces where I shouldn't have and didn't have them where I should.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •