A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Running a Macro when email arrives



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 4th 10, 04:52 AM posted to microsoft.public.outlook.program_vba
Gardos Catalin
external usenet poster
 
Posts: 1
Default Running a Macro when email arrives

Hello everybody. I trie to make a macro that print my incoming email that
contains in subject word "Comanda online".
This is the macro:

Private Sub Application_NewMail()

CheckMail

End Sub


Public Sub CheckMail()
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim oOApp As Outlook.Application
Dim oOMail As Outlook.MailItem
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim Subject As String


Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFold erInbox)
Set InboxItems = Inbox.Items
For Each Mailobject In InboxItems
If Mailobject.UnRead Then
Subject = Mailobject.Subject
If Subject = "Comanda online" Then
Mailobject.PrintOut
End If
Mailobject.UnRead = False
End If
Next

Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
End Sub

It's working, but i want to print only the body of the email.
Is this possible ?

Thank you.
Hope to reply to me.

url:http://www.ureader.com/msg/1081942.aspx
Ads
  #2  
Old January 4th 10, 07:30 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Running a Macro when email arrives



I'd probably create a Word document, insert the body of the email, and then
print the document instead of the email.

--
Best regards
Michael Bauer - MVP Outlook
Manage and share your categories:
http://www.vboffice.net/product.html?pub=6&lang=en


Am Mon, 4 Jan 2010 12:52:58 +0800 schrieb Gardos Catalin:

Hello everybody. I trie to make a macro that print my incoming email that
contains in subject word "Comanda online".
This is the macro:

Private Sub Application_NewMail()

CheckMail

End Sub


Public Sub CheckMail()
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim oOApp As Outlook.Application
Dim oOMail As Outlook.MailItem
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim Subject As String


Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFold erInbox)
Set InboxItems = Inbox.Items
For Each Mailobject In InboxItems
If Mailobject.UnRead Then
Subject = Mailobject.Subject
If Subject = "Comanda online" Then
Mailobject.PrintOut
End If
Mailobject.UnRead = False
End If
Next

Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
End Sub

It's working, but i want to print only the body of the email.
Is this possible ?

Thank you.
Hope to reply to me.

url:http://www.ureader.com/msg/1081942.aspx

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a Macro when email arrives Sue Mosher [MVP][_3_] Outlook and VBA 0 July 9th 09 02:17 PM
Running a Macro when email arrives Rob Girard Outlook and VBA 0 July 9th 09 12:07 PM
Running a Macro when email arrives Irwin Quintana Outlook and VBA 0 September 23rd 08 06:27 PM
Outlook 2k: running vba when new mail arrives Brian Schwartz Outlook and VBA 1 November 13th 06 10:54 PM
Outlook 2k: running vba when new mail arrives Brian Schwartz Outlook and VBA 0 November 13th 06 10:38 PM


All times are GMT +1. The time now is 01:49 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.