473,698 Members | 2,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.sendobjec t

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 strAttachmentPa th As String, _
Optional booDisplayMsg As Boolean = False)

Dim objOutlook As Object, _
objOutlookMsg As Object, _
objOutlookRecip As Object, _
objOutlookAttac h As Object

'create the Outlook session:
Set objOutlook = CreateObject("O utlook.Applicat ion")

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

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

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

'add the bcc recipients:
If Not IsMissing(strEm ailBCC) 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(strAtta chmentPath) Then
Set objOutlookAttac h = .Attachments.Ad d(strAttachment Path)
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 2322

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

Similar topics

2
3977
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 used the late binding code: Dim objOutlook as object Set objOutlook = CreateObject("Outlook.Application") Set objOutlookMsg = objOutlook.CreateItem(0) etc...
0
1420
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 ( http://support.microsoft.com/default.aspx?scid=kb;EN-US;302902 ) which gives a good example for work. I understand the InvokeMember techniques used here. But I don't know how to apply this to PowerPoint since I don't know how to navigate within the...
9
6844
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. IT MUST BE LATE-BINDING THOUGH. I need to be able to open an existing contact folder or create a new contact folder, and add new contacts to it.
4
5104
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 things happening will be: a new email is created and some text is placed in the body, then the email window is displayed. The user can close the window or select some recipients and send the message. I would like some info on how to do this correctly....
30
2825
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 integer The integers in these arrays are actually pointers to different columns of data in a text file.
2
4143
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 for Outlook 2000. I don't want the user to go and find the reference file in Access. So I need this code to work for all versions. I think I need to use late binding but don't know anything about it. Here is the function: Dim OlkApp As...
0
1447
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 binding but it appears I'm not having much luck. The code works ONLY if Outlook is loaded. I'm a bit unfamiliar with Outlook...been using Netscape for way too long. When I start Outlook, it prompts me for a profile. How do you handle that via...
1
2766
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
1071
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
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8861
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.