|
-
Aug 13th, 2007, 01:15 AM
#1
Thread Starter
Lively Member
[RESOLVED] Sendkeys from Excel to Outlook
Im sending an email from an excel VBA and our internal IT guys have instigated a security classifycation requirement for all emails.
When you Send you get a box with a list and you have to choose a level of security. (I work in a big govt dept).
I am trying to set that with "Sendkeys" but I only get error message "Object doesnt support this property or code." Should Outlook support Sendkeys?
When running it the box has focus and you only need to hit DOWN DOWN ENTER to get what I want. then it continues. This code is mostly from this forum.
Code:
Private Sub CommandButton3_Click()
'Add a reference to MS Outlook xx.0 Object Library
Dim oApp As Outlook.Application
Dim oEmail As Outlook.MailItem
Set oApp = New Outlook.Application
Set oEmail = oApp.CreateItem(olMailItem)
With oEmail
.To = "[email protected]"
.Subject = "What ever your subject is"
.BodyFormat = olFormatPlain
.Body = "...text here..."
.Importance = olImportanceHigh
'.ReadReceiptRequested = True
.Recipients.ResolveAll
.Save
.Display 'Show the email message and allow for editing before sending
.SendKeys "{DOWN}{DOWN}{ENTER}", True
.Send 'You can automatically send the email without displaying it.
End With
Set oEmail = Nothing
'oApp.Quit
Set oApp = Nothing
End Sub
This all works fine appart from needing to set the security. It comes up and you can manually select it and then it proceeds.
If I put the .Sendkeys line after .Send it doesnt get that far before needing input to the security box.
any ideas
-
Aug 13th, 2007, 03:59 AM
#2
Re: Sendkeys from Excel to Outlook
Thats because the Security Prompt is modal so anything after the .SEnd line will stop and not be processed until you dismiss the dialog. Try using Click Yes instead.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 12th, 2007, 10:13 PM
#3
Thread Starter
Lively Member
Re: Sendkeys from Excel to Outlook
Thanks for the thought but I didnt get to try it.
'Security' decided it needs to be done manually by a person anyway.
Makes sense.
-
Nov 13th, 2007, 04:33 AM
#4
Re: [RESOLVED] Sendkeys from Excel to Outlook
Ok, yes its not usually something net admins like to have, bypassing any security is usually forbidden.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 13th, 2007, 04:48 PM
#5
Re: [RESOLVED] Sendkeys from Excel to Outlook
SendKeys is a command from VBA Application.
The error message tells you that SendKeys is not a property or method of oEmail.
You cannot use
Code:
With oEmail
.SendKeys "{DOWN}{DOWN}{ENTER}", True
It must be without the "dot":
Code:
SendKeys "{DOWN}{DOWN}{ENTER}", True
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|