Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 79
Default Please help VBA code not working properly send email when due dates

Hello i am looking for a VBA coding that allows to have an email once
one of the employe has an expiry date to be renewed
Example :
Sheet name : expiry dates
D1= Employee Name Row 4
E1= Birthdate row 5
F1= Passport renewal date
J1= Driving license renewal date
H1= Visa card renewal date
And list of columns for expiry dates till row AJ1 Row 36
Ak1 = Supervisor name to send the email to row 37
AL = email adress to send the mail to row 38

I want a text informing me that this employee needs the following* to
be renewed for him

I CHECK THIS SITE BUT I AM A BIGGINER IN VBA i didnt understand it
http://www.rondebruin.nl/mail/change.htm

I have made a search and found the following but it is not working
properly i dont know what i made wrong
Best Regards

The code that i used is as followed pasted in workbook


Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As
String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal
lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub SendEMail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Dim r As Integer, x As Double
For r = 4 To 5 'data in rows 4-5
' Get the email address
Email = Cells(r, 34)

' Message subject
Subj = "Upcoming Expiration Date(s)"

' Compose the message
Msg = ""
'Supervisor Name below
Msg = Msg & "Dear " & Cells(r, 33) & "," & vbCrLf & vbCrLf
Msg = Msg & "The following employee has a due date set to
expire on "
'Expiration Date
Msg = Msg & Cells(r, 4).Text & "." & vbCrLf & vbCrLf
Msg = Msg & "Tia kareem" & vbCrLf
Msg = Msg & "HR Manager"

' Replace spaces with %20 (hex)
Subj = Application.WorksheetFunction.Substitute(Subj, " ",
"%20")
Msg = Application.WorksheetFunction.Substitute(Msg, " ",
"%20")

' Replace carriage returns with %0D%0A (hex)
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf,
"%0D%0A")
' Create the URL
URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg

' Execute the URL (start the email client)
ShellExecute 0&, vbNullString, URL, vbNullString,
vbNullString, vbNormalFocus

' Wait two seconds before sending keystrokes
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%s"
Next r
End Sub






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
send email to each customer email in excel sheet. -keevill- Excel Discussion (Misc queries) 3 July 17th 08 02:33 PM
Code to send email to address within selection in Excel workbook vic1 Excel Discussion (Misc queries) 3 May 28th 08 09:51 PM
send wkbk as an email attachment with an email address copied from SueInAtl Excel Discussion (Misc queries) 0 May 21st 07 10:53 PM
VBA Excel code not working properly (HELP!) zulfer7 Excel Discussion (Misc queries) 3 April 5th 07 10:49 PM
Worksheets Don't Properly Send When Emailing Erin Excel Discussion (Misc queries) 0 September 28th 06 05:16 PM


All times are GMT +1. The time now is 06:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"