LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default sending email with Outlook using Excel


I'm just trying to send a basic message to a list of people with
Microsoft Outlook using Excel. I thought that it would be a great idea
to, once a macro finished, put a snippet of code that sends an email to
others that are waiting on this particular macro to finish that says
"File's Done!". I've googled and here's the best I could find, problem
is, it opens the email but you have to press the send button. How can I
get this to automatically send?

Code:
--------------------
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

' Get the email address
Email = ; "

' Message subject
Subj = "The File you've been waiting for"

' Compose the message
Msg = "File is Done!"

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


--
DKY
------------------------------------------------------------------------
DKY's Profile:
http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=517398

 
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
How to link to an Excel file when sending an email in Outlook? BFree Excel Discussion (Misc queries) 2 May 1st 06 11:43 AM
How to get rid of the warning msg from Outlook when sending email via VBA code in Excel Macgru Excel Programming 0 April 14th 05 09:30 PM
How to get rid of the warning msg from Outlook when sending email via VBA code in Excel Sunil Jayakumar Excel Programming 0 April 14th 05 11:11 AM
How to get rid of the warning msg from Outlook when sending email via VBA code in Excel Fredrik Wahlgren Excel Programming 0 April 14th 05 10:53 AM
sending email from excel using outlook express Sam Excel Programming 2 August 28th 04 11:09 PM


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

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"