![]() |
|
|
|
#1
|
|||
|
|||
|
I'm using an MS Access command to open Outlook. I can get it to open, fill in address, subject, and text, but what I haven't been able to conquer is to get it to send without a mouse click on the send button within Outlook.
I want the email to fill in and send without human interaction. Any suggestions will be appreciated. |
|
#2
|
||||
|
||||
|
As stated on this board's opening page (https://www.msofficeforums.com/):
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
I wasn't sure whether the issue was with Outlook or Access, frankly. I was hoping for the input of people well versed with Outlook and that's why I posted here.
|
|
#4
|
||||
|
||||
|
Without seeing your code, it'd be difficult for anyone to say what the problem is. Does it have a '.Send' command (eg objMailItem.Send)?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
No. I wasn't familiar with that command. If that's a valid command then very likely that's all I have to do.
I've actually used a macro with the SendObject action, rather than code, but I can easily change that to code to add the coded instruction. BTW, is there a similar command within a macro? |
|
#6
|
||||
|
||||
|
The .Send command is part of the Outlook vba object model. So, yes, it's a macro command.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#7
|
|||
|
|||
|
Just out of curiosity, how do you access .Send from within a macro?
|
|
#8
|
||||
|
||||
|
Without seeing your code, which you've still not provided, I can't tell you how/where to add it to that. Here's a generic demonstration. The code assumes you're using early binding:
Code:
Sub Demo()
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objMailItem As Outlook.MailItem
Dim objRecipient As Outlook.Recipient
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objMailItem = objOutlook.CreateItem(olMailItem)
With objRecipient
.Add ("John Wilson")
.Type = olTo
.Add ("Adrian Fearnley")
.Type = olTo
.Add ("Chuck Feathers")
.Type = olcc
End With
With objMailItem
.Subject = "Financial Analysis"
.Body = "Hi John, Adrian & Chuck," & vbCr & "I hope all's well. Here's the financial analysis." & _
vbCr & vbCr & "Regards" & Environ("UserName")
.Attachments.Add ("C:\Users" & Environ("UserName") & "\Documents\Financials.xls")
.Logon , , True
.Send
End With
Set objMailItem = Nothing: Set objNameSpace = Nothing: Set objOutlook = Nothing
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Programatically Managing Word Document Structure
|
mlbliss | Word VBA | 3 | 11-07-2012 07:42 PM |
Apply font color programatically using VBA Word
|
divakarganta | Word VBA | 3 | 08-08-2012 08:05 PM |
How to send an email to all contacts I ever send an email to?
|
JSYdeJong | Outlook | 1 | 11-02-2011 07:22 PM |
Can't send email
|
helpplease | Outlook | 6 | 12-21-2008 06:00 AM |
| Programatically open Outlook folder (set focus) using RDO? | NicMic | Outlook | 0 | 01-10-2008 03:27 PM |