Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Macro to send email automatically.

I have a macro set up to send an email to users when there password is due to
expire.

How do i get the email to actually send. The mail is populated and ready to
send but wont actually go. Is there a line i need to add at the end of the
macro to send the mail?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Macro to send email automatically.

Show your code
Which mail program do you use ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Dan Wood" wrote in message ...
I have a macro set up to send an email to users when there password is due to
expire.

How do i get the email to actually send. The mail is populated and ready to
send but wont actually go. Is there a line i need to add at the end of the
macro to send the mail?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Macro to send email automatically.

The mail programe is Outlook, and the code is as follows:-

Sub SendEmail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Email = Range("H1")
For Each c In Range("D7:D30")
If c.value = 0 Then
SySname = c.Offset(, -3).value
Subj = SySname

Msg = ""
Msg = Msg & "Hi" & Cells(ActiveCell.Row, 6) & "," & vbCrLf & vbCrLf &
"Your AS400 password is due to expire on the above mentioned system. Please
log on and change your password" & vbCrLf & vbCrLf & "Once you have done this
please update the spreadsheet to reflect the new password, and the date it
was changed."

'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"

End If
Next
End Sub


"Ron de Bruin" wrote:

Show your code
Which mail program do you use ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Dan Wood" wrote in message ...
I have a macro set up to send an email to users when there password is due to
expire.

How do i get the email to actually send. The mail is populated and ready to
send but wont actually go. Is there a line i need to add at the end of the
macro to send the mail?

.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Macro to send email automatically.

Uncomment this two lines (remove the ' before it)

'Application.Wait (Now + TimeValue("0:00:02"))
'Application.SendKeys "%s"

If you use Outlook there are other examples that use the Outlook object modelalso on my site
Sendkeys is not a very good option to use
http://www.rondebruin.nl/sendmail.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Dan Wood" wrote in message ...
The mail programe is Outlook, and the code is as follows:-

Sub SendEmail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Email = Range("H1")
For Each c In Range("D7:D30")
If c.value = 0 Then
SySname = c.Offset(, -3).value
Subj = SySname

Msg = ""
Msg = Msg & "Hi" & Cells(ActiveCell.Row, 6) & "," & vbCrLf & vbCrLf &
"Your AS400 password is due to expire on the above mentioned system. Please
log on and change your password" & vbCrLf & vbCrLf & "Once you have done this
please update the spreadsheet to reflect the new password, and the date it
was changed."

'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"

End If
Next
End Sub


"Ron de Bruin" wrote:

Show your code
Which mail program do you use ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Dan Wood" wrote in message ...
I have a macro set up to send an email to users when there password is due to
expire.

How do i get the email to actually send. The mail is populated and ready to
send but wont actually go. Is there a line i need to add at the end of the
macro to send the mail?

.

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
Macro to send worksheet via email Julie Excel Discussion (Misc queries) 2 January 22nd 09 06:41 AM
macro to send email scheduler Excel Discussion (Misc queries) 2 October 18th 07 11:20 PM
use excel to send email without macro Aaron Excel Discussion (Misc queries) 4 July 3rd 07 04:19 PM
Can you send a Macro to someone else by email? Greenback Excel Discussion (Misc queries) 3 August 2nd 06 01:01 PM
How do I automatically send daily email of updated Excel workbook. How to automate emails with excel file. Excel Discussion (Misc queries) 1 May 9th 05 08:55 PM


All times are GMT +1. The time now is 10:38 PM.

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

About Us

"It's about Microsoft Excel"