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

email



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 6th 06, 08:25 AM posted to microsoft.public.outlook.program_vba
jatman
external usenet poster
 
Posts: 4
Default email

i have a code that sends an excel worksheet/workbook to a recipient. but the
problem lies when the user does not have microsoft open to email the sheet.
the email just sits in the outbox waiting for the user to start the
application and then sends it out - sometimes days later; is there a code
that can be used in excel (script) to open microsoft outlook and acutally
email it also?
  #2  
Old September 6th 06, 06:20 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default email

This code hooks into Outlook if it's already open or opens it and quits if it
is not open, sending the e-mail immediately in both cases. I'm not sure if
you're automating Excel's SendMail method or not, but if you are you should
recode to automate the Outlook Object Model instead.

Dim objOL As Outlook.Application, blnNewOutlook As Boolean
Dim objExp As Outlook.Explorer
Dim objNS As Outlook.NameSpace
Dim objMail As Outlook.MailItem

'Retrieve an existing Outlook Application object if it is already loaded
Set objOL = GetObject(, "Outlook.Application")
If objOL Is Nothing Then
'Outlook is closed; open it
Set objOL = New Outlook.Application
blnNewOutlook = True
End If
Set objNS = objOL.GetNamespace("MAPI")

If blnNewOutlook = True Then
Set objExp =
objOL.Explorers.Add(objNS.GetDefaultFolder(olFolde rInbox),
olFolderDisplayNormal)
objExp.Activate 'Show Outlook
End If

Set objMail = objOL.CreateItem(olMailItem)
objMail.Subject = "test"
objMail.To = "
objMail.Send

Set objMail = Nothing

If blnNewOutlook = True Then
objExp.Close
objOL.Quit
End If

Set objExp = Nothing
Set objNS = Nothing
Set objOL = Nothing

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"jatman" wrote:

i have a code that sends an excel worksheet/workbook to a recipient. but the
problem lies when the user does not have microsoft open to email the sheet.
the email just sits in the outbox waiting for the user to start the
application and then sends it out - sometimes days later; is there a code
that can be used in excel (script) to open microsoft outlook and acutally
email it also?

 




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


All times are GMT +1. The time now is 12: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.