473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Outlook Automation Late Binding

I have created the code below to send e-mail using late binding
Outlook Automation.

I have three questions though...

Can I send an Access report without haveing to output and save it as a
file as I can do using docmd.sendobject

How can I get Outlook to send the message automatically if it's not
open instead of having the mail sit in the outbox?

Is this code sound?

Thanks,
lq

Function SendOutlookMail(strEmailTo As String, _
strSubject As String, _
strMsgTxt As String, _
Optional strEmailCC As String, _
Optional strEmailBCC As String, _
Optional strAttachmentPath As String, _
Optional booDisplayMsg As Boolean = False)

Dim objOutlook As Object, _
objOutlookMsg As Object, _
objOutlookRecip As Object, _
objOutlookAttach As Object

'create the Outlook session:
Set objOutlook = CreateObject("Outlook.Application")

'create the message object:
Set objOutlookMsg = objOutlook.CreateItem(0)

With objOutlookMsg
'add the recipients:
Set objOutlookRecip = .Recipients.Add(strEmailTo)
objOutlookRecip.Type = 1 'olTo

'add the cc recipients:
If Not IsMissing(strEmailCC) Then
Set objOutlookRecip = .Recipients.Add(strEmailCC)
objOutlookRecip.Type = 2 'olCC
End If

'add the bcc recipients:
If Not IsMissing(strEmailBCC) Then
Set objOutlookRecip = .Recipients.Add(strEmailBCC)
objOutlookRecip.Type = 3 'olBCC
End If

.Subject = strSubject
.Body = strMsgTxt & vbCrLf
.Importance = 2 '>high importance

'add attachment:
If Not Isblank(strAttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(strAttachmentPath)
End If

'resolve each recipient name:
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

If booDisplayMsg Then
.Display
Else
.Send
End If
End With

Set objOutlookMsg = Nothing
Set objOutlook = Nothing

End Function
Nov 12 '05 #1
0 2287

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Blake | last post by:
I'm using late binding to create Outlook email from an Access2K database. I am not referencing the Microsoft Office 9.0 Object Library nor the Microsoft Outlook 9.0 Object Library. Instead, I have...
0
by: Dick Peterson | last post by:
I am trying to automate a PowerPoint process from C#, using late binding because the app needs to be independent of Office versions. I found an article on this in MSKB article 302902 (...
9
by: John Smith | last post by:
Hey, I'm having a difficult time finding some good examples of late binding Outlook in C#. Anyone know of any good sites out there? I've googled and MSDN'ed, but have come up a bit empty. ...
4
by: Max | last post by:
Hi, I would like to have a button and a combo box with options to select various versions of Microsoft Outlook: 2002, 2003. The user selects the email client and clicks the button. The only...
30
by: lgbjr | last post by:
hi All, I've decided to use Options Strict ON in one of my apps and now I'm trying to fix a late binding issue. I have 5 integer arrays: dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as...
2
by: Ecohouse | last post by:
I've written a function to check emails in Outlook using Access which works. But I need to be able to have it work for different version of Outlook. I'm using Outlook 2002 and I need to also work...
0
by: salad | last post by:
I'm on A97 and have Outlook 2003 on the computer. There's some generic code at Tony Toew's site and at MS and on the web that's very similar....but I can't make it work. I want to use late...
1
by: =?Utf-8?B?U3RldmUgUmFuZGFsbA==?= | last post by:
Hi, Does anyone have any code samples (or links to) for sending an email message via outlook using late binding? Many thanks.
0
by: =?Utf-8?B?U3RldmUgUmFuZGFsbA==?= | last post by:
Hi, Does anyone have any code samples in C# (or links to) for sending an email message via outlook using late binding? Many thanks.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.