PDA

View Full Version : Using sendkeys from word



boc_est1986
03-04-2010, 12:05 AM
I have a macro that is written in Word that sends an email with the active document as an attachment. I was using the .send method fine but now get the microsoft guard error "A program is trying to automatically send an email". To avoid this error i would liek to use the .display function and then use sendkeys to simulate ctrl + enter being pressed. Here is the code

Set olMail = olApp.CreateItem(0)
olMail.To = addresses
olMail.Subject = "Please action the attached EQN"
olMail.Body = "Please find attached the EQN"
olMail.Attachments.Add (ActiveDocument.FullName)
olMail.Display

AppActivate ("Please action the attached EQN - Message"), True

SendKeys ("^{ENTER}"), True
The code runs but the sendkeys dont work as the email stays displayed and doesn't send however i dont get any error messages. Please can you help