+ Reply to Thread
Results 1 to 2 of 2

Macro to send mail on every friday and on month end

  1. #1
    Registered User
    Join Date
    03-05-2014
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Macro to send mail on every friday and on month end

    Hi Everyone,

    i have written macro to send mail on every friday and on last date of every month. But when i run the mcaro i am getting error. subject line in the mail should change according to the weeks (eg: for this week suject should be enter eforts from 03/17/2014 to 03/19/2014).I have another doubt , can we able to attach a screenshot in the body of the mail.Please help me.

    Public Sub Mail_small_Text_Outlook()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim dat As Date, y As Date, z As Date
    Dim str As String, abc As String
    str = WeekdayName(Weekday(Now()))
    dat = Date
    y = dat - 7
    z = Application.WorksheetFunction.EoMonth(dat, 0)
    abc = "Today is not friday or month end. So i cannot send the mail"

    If (str = friday) Then
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    strbody = "Hi All" & vbNewLine & vbNewLine & _
    "Please enter your efforts for the period of (" y "to" dat ")before Today EOD" & vbNewLine & _
    "<B> Note: </B>" & vbNewLine & _
    "Please remember to create tasks with Phase, Activity and Task mapping" & vbNewLine & _
    'Above line should be displayed in red
    "Make sure that you have chosen Guardian as your C2.0 project before entering your efforts"& vbNewLine & _
    'Above line should be displayed in red
    "<B>Planned hours for any task cannot exceed 45hrs</B>"& vbNewLine & _
    'Above line should be displayed in red
    "This is line 4"& vbNewLine & _

    On Error Resume Next
    With OutMail
    .To = "xxxx@company.com"
    .CC = ""
    .BCC = ""
    .Subject = "Enter the efforts for the period (03/17/2014 to 03/21/2014)"
    'In the above subject line period should change according to the week can we able to write like that
    .Body = strbody
    'You can add a file like this
    '.Attachments.Add ("C:\test.txt")
    .Send 'or use .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
    Else
    If (dat = z) Then
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    strbody = "Hi All" & vbNewLine & vbNewLine & _
    "Please enter your efforts for the whole month" & vbNewLine & _
    "<B> Note: </B>" & vbNewLine & _
    "Please remember to create tasks with Phase, Activity and Task mapping" & vbNewLine & _
    'Above line should be displayed in red
    "Make sure that you have chosen Guardian as your C2.0 project before entering your efforts"& vbNewLine & _
    'Above line should be displayed in red
    "<B>Planned hours for any task cannot exceed 45hrs</B>"& vbNewLine & _
    'Above line should be displayed in red
    "This is line 4"& vbNewLine & _

    On Error Resume Next
    With OutMail
    .To = "xxxx@company.com"
    .CC = ""
    .BCC = ""
    .Subject = "Enter the efforts for the period (03/1/2014 to 03/31/2014)"
    'In the above subject line period should change according to the week can we able to write like that
    .Body = strbody
    'You can add a file like this
    '.Attachments.Add ("C:\test.txt")
    .Send 'or use .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
    Else
    MsgBox abc
    End Sub

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Macro to send mail on every friday and on month end

    Welcome to the forum.

    We'd like to help you but first..

    Pls take some minutes to read forum rules and specially-in this case- rule#3 and add code tags around your code.
    Then anyone will be able to help you.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 03-11-2014, 12:24 PM
  2. How to e-mail selected row and use e-mail address in a cell to send e-mail from excel
    By syedalamgir in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2010, 02:15 AM
  3. Send Mail Macro
    By jregan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2010, 07:34 PM
  4. Send Mail Macro
    By jregan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2010, 03:50 PM
  5. using macro to send e-mail
    By bob777 in forum Excel General
    Replies: 1
    Last Post: 11-02-2005, 07:20 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1