A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Sending Outlook message programmatically



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5  
Old November 5th 07, 02:59 PM posted to microsoft.public.outlook.program_vba
JP[_2_]
external usenet poster
 
Posts: 18
Default Sending Outlook message programmatically

Here's some sample code I use in Excel to send emails using Outlook.


Dim Outlook As Outlook.Application
Dim OutlookMsg As Outlook.MailItem
Dim OutlookRecip As Outlook.Recipient
Dim OutlookAttach As Outlook.Attachment

Set Outlook = CreateObject("outlook.application")
Set OutlookMsg = Outlook.CreateItem(olMailItem)

With OutlookMsg
.SentOnBehalfOfName = "
.ReplyRecipients.Add
")
.Subject = "Read me!"
.Importance = olImportanceHigh
.Sensitivity = olConfidential
.BodyFormat = olFormatHTML
.HTMLBody = "Your message here"

Set OutlookRecip = ")
OutlookRecip.Type = olTo

Set OutlookAttach = .Attachments.Add("C:\Documents And
Settings\username\Desktop\filename.xls")
.Send ' or .Display if you want to preview the message

'destroy variables
Set OutlookRecip = Nothing
Set OutlookAttach = Nothing
Set OutlookMsg = Nothing
Set Outlook = Nothing


Beware Outlook security warning!



HTH,
JP

On Nov 2, 9:23 am, dmklaus wrote:
Outlook 2003, the sender would be a mailbox (for example:
)



"dmklaus" wrote:
I am building automated email messaging, populating the Subject, message and
recipients from within my application. I need to popultat the From: also,
does anyone know how to code this?- Hide quoted text -


- Show quoted text -



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programmatically sending email via Outlook COM Add-In pollyanna65 Add-ins for Outlook 6 January 29th 07 04:47 PM
How can I programmatically display an email message saved in a msg file? Clive Outlook - Using Forms 1 November 29th 06 09:39 PM
Programmatically sending email from Access scariharry Outlook and VBA 0 July 5th 06 05:08 PM
Sending a test message works; sending a message doesn't? NancyTG Outlook - Installation 9 June 22nd 06 04:00 PM
Error message when sending message in Outlook Vikes Outlook - General Queries 0 February 17th 06 10:02 PM


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.