473,385 Members | 1,370 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,385 software developers and data experts.

Question re Application Automation

Basic Outlook Automation (including Send New e-Mail)
Expand|Select|Wrap|Line Numbers
  1. ' Requires A References to the Microsoft Outlook Object Library
  2. ' in VBE, select Tools->References, and ensure it is checked
  3.  
  4. Private Sub ExportToOutlook()
  5.     ' Variable Declaration
  6.     Dim objOutlook as Object
  7.     Dim objEMail as Object
  8.  
  9.     ' If Outlook is open, use GetObject, otherwise open Outlook
  10.     Set objOutlook = GetObject(, "Outlook.Application")
  11.     If objOutlook Is Nothing Then Set objOutlook = CreateObject("Outlook.Application")
  12.  
  13.     ' Creates a new e-mail
  14.     Set objEMail = objOutlook.CreateItem(0)
  15.     With objEMail
  16.  
  17.         ' Adds To Recipient
  18.         Set ToContact = .Recipients.Add("Me@Gmail.Com")
  19.  
  20.         ' Adds CC recipient
  21.         ToContact.Type = olCC
  22.         Set ToContact = .Recipients.Add("You@Gmail.com")
  23.  
  24.         ' Sets the Subject
  25.         .Subject = "Service Report 1234"
  26.  
  27.         ' Sets the Body
  28.         .Body = "Attached herein are the Reports"
  29.  
  30.         ' Adds attachment
  31.         .Attachments.Add "c:\Service Report 1234", olByValue, , "Service Report"
  32.  
  33.         ' Embeds attachment
  34.         .Attachments.Add "c:\JoeBob.gif", olEmbeddedItem, , "Joe Bob's Picture"
  35.  
  36.         ' Receipt upon delivery
  37.         .OriginatorDeliveryReportRequested = True
  38.  
  39.         ' Recipt upon read
  40.         .ReadReceiptRequested = True
  41.  
  42.         ' Displays the E-Mail
  43.         .Display
  44.  
  45.         ' Sends the E-Mail
  46.         .Send
  47.  
  48.         ' Saves a Draft of the E-Mail
  49.         .Save                                        
  50.     End With
  51.  
  52. End Sub
With your outlook example can you use a querry to fill in the parts needed for the email such as body, send to etc.. ? What woud it look like?
Jun 28 '07 #1
1 1222
NeoPa
32,556 Expert Mod 16PB
This post was appended to an article (Application Automation).
This is a question so I've moved it the Access Forum, where it belongs.
Jun 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Shuttermutt | last post by:
Good day, all! I'm wondering if it's possible to write two applications so that they can each compile to their own EXE, but one application can manipulate the objects on the other application. For...
2
by: john_20_28_2000 | last post by:
What is the technology that replaces OLE Automation in .NET? Please. Sorry, I couldn't find it. Also, I wanted to know if I have a program, any executable, can I "automate" it from .net, c#,...
4
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone...
12
by: Joe | last post by:
Hello All: I'm sure that one of you can quickly spot the error in my script. I am using a small javascript function to retrieve the text of a hyperlink in a datagrid column. Here is my...
5
by: Geoff Jones | last post by:
Hi I have a DLL written in C++/MFC which has functions in it. I would like to use it within a VB.net application. However, when I try to add a reference to it, I'm told that "it isn't a valid...
12
by: Boris Borcic | last post by:
Hello, I am trying to use UI Automation to drive an MS Windows app (with pywinauto). I need to scrape the app's window contents and use some form of OCR to get at the texts (pywinauto can't...
6
by: Gunawan | last post by:
Dear All, I have create an excel (COM Object) using this code Excel.Application xls = new Excel.Application(); but I can not remove it from memory although I have using close and quit ...
9
NeoPa
by: NeoPa | last post by:
In VBA (I expect VB would be similar) controlling another Office Application (Automation) can be done using the following steps : Ensure the Reference (VBA Window / Tools / References) has been...
4
by: Keith Wilby | last post by:
How controllable from Access VBA is Excel? I'm currently using automation to dump 2 columns of data into an Excel spreadsheet so that the end user can create a line graph based on it. Could the...
9
by: salad | last post by:
I have the following code. I have a reference to the Outlook library in the reference list. My machine is standalone, not on a network. Dim Olapp As Outlook.Application Set Olapp =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.