VBA Express Forum  




Go Back   VBA Express Forum > VBA Code & Other Help > Outlook Help
     Feedback     
Register FAQ Members Arcade Knowledge Base Training Articles Consulting

Reply
 
Thread Tools Display Modes
Old 09-25-2007, 11:22 PM   #1
ahmedv

 
Joined: Sep 2007
Posts: 4
Kb Entries: 0
Articles: 0
Outlook Vba Newmail Help

Good day,

Im looking for some help for a macro for Oulook 2003.

Basically I need the macro to check for new mail with a certain specified subject, thereafter i need the macro to copy to the clipboard the content of the email, and therafter once the message is copied to auto press CTRL+SHIFT+P - to launch one of my other applications.

Any idea's - im a bit new to VBA so any help would be appreciated
Thanks
Ahmed

Local Time: 03:57 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 09-27-2007, 01:11 PM   #2
Oorang
 
Oorang's Avatar
Knowledge Base Approver

 
Joined: Jan 2007
Posts: 1,135
Kb Entries: 15
Articles: 0
Untested, but this should do it for you.
VBA:
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String) Const strKeyPhrase_c As String = "Foo" Const strDlmtr_c As String = "," Dim mai As Outlook.MailItem 'MUST SET REFERENCE TO: C:\WINDOWS\system32\FM20.dll ' Dim cb As MSForms.DataObject Dim varEntryIDs As Variant Dim varEID As Variant Set cb = New MSForms.DataObject varEntryIDs = VBA.Split(EntryIDCollection, strDlmtr_c, compare:=vbBinaryCompare) For Each varEID In varEntryIDs Set mai = Application.Session.GetItemFromID(varEID) If VBA.InStrB(mai.Subject, strKeyPhrase_c, compare:=vbTextCompare) Then cb.SetText mai.Body cb.PutInClipboard VBA.SendKeys "^+p", True End If Next End Sub
VBA tags courtesy of www.thecodenet.com


Cordially,
Aaron



Keep Our Board Clean!
  • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
  • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

Local Time: 04:57 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 10-01-2007, 01:34 AM   #3
ahmedv

 
Joined: Sep 2007
Posts: 4
Kb Entries: 0
Articles: 0
Thanks

Thanks,

I got it to run, the only problem im having now is the SendKeys

I require the keys Ctrl+Shift+P to be pressed as a last step - any advise?

Thanks


Local Time: 03:57 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 10-01-2007, 03:40 PM   #4
Oorang
 
Oorang's Avatar
Knowledge Base Approver

 
Joined: Jan 2007
Posts: 1,135
Kb Entries: 15
Articles: 0
That is what this line does:
VBA:
VBA.SendKeys "^+p", True
VBA tags courtesy of www.thecodenet.com


Cordially,
Aaron



Keep Our Board Clean!
  • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
  • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

Local Time: 04:57 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 10-01-2007, 10:53 PM   #5
ahmedv

 
Joined: Sep 2007
Posts: 4
Kb Entries: 0
Articles: 0
Plugged that code in, still not working, however if i manually press the keys they work, any other idea's

Local Time: 03:57 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 10-02-2007, 07:20 AM   #6
Oorang
 
Oorang's Avatar
Knowledge Base Approver

 
Joined: Jan 2007
Posts: 1,135
Kb Entries: 15
Articles: 0
Hmmm probabbly need a different way to trigger. Sendkeys you have to get just right. Is ctrl-shift-p triggering another vba script? If not what is it triggering?


Cordially,
Aaron



Keep Our Board Clean!
  • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
  • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

Local Time: 04:57 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 10-07-2007, 10:41 PM   #7
ahmedv

 
Joined: Sep 2007
Posts: 4
Kb Entries: 0
Articles: 0
Its not triggering anything, tried to change the keys as well, no luck

mmm how can i launch an .exe from the application, possible i can launch the app and then try?

Thanks

Local Time: 03:57 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 10-08-2007, 06:21 AM   #8
Oorang
 
Oorang's Avatar
Knowledge Base Approver

 
Joined: Jan 2007
Posts: 1,135
Kb Entries: 15
Articles: 0
vba.shell "C:\MyPath\MyExe.exe"


Cordially,
Aaron



Keep Our Board Clean!
  • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
  • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

Local Time: 04:57 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 01:57 PM.


Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright © 2004 - 2012 VBA Express