![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
I have an question, I'm relatively new to VBA coding. Especially in Outlook,
I am running an Exchange 2003 server using Outlook 2003 clients. What I am needing is code that will run when a specific sender sends an email to me with a specific (text) in the body of the email. I then want it forward/email to an outside email recipient. I am aware that you can activate automatic email forwarding in the Exchange server, however I view this as a major security risk. Any assistance would be greatly welcomed |
Ads |
#2
|
|||
|
|||
![]()
You can certainly write code for that but it probably would be much easier
for you to just create a rule to do that. Start with a blank rule and select the conditions for certain senders and specified text in the subject, then select the forward action for the rule. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "TerryM" wrote in message ... I have an question, I'm relatively new to VBA coding. Especially in Outlook, I am running an Exchange 2003 server using Outlook 2003 clients. What I am needing is code that will run when a specific sender sends an email to me with a specific (text) in the body of the email. I then want it forward/email to an outside email recipient. I am aware that you can activate automatic email forwarding in the Exchange server, however I view this as a major security risk. Any assistance would be greatly welcomed |
#3
|
|||
|
|||
![]()
What you wrote is totally true except for the fact that Exchange by default
disables automatic forwarding to external sources. That is the reason why I was wanting code to basically take the email with the specific sender and text in the body and automatically create a new email and send it out. This way Exchange doesn't view it as a forward to an outside location. You can manually send to outside locations, however you can't automatically forward emails to outside locations without enabling this function. And that security wise is something I do not want to do. "Ken Slovak - [MVP - Outlook]" wrote: You can certainly write code for that but it probably would be much easier for you to just create a rule to do that. Start with a blank rule and select the conditions for certain senders and specified text in the subject, then select the forward action for the rule. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "TerryM" wrote in message ... I have an question, I'm relatively new to VBA coding. Especially in Outlook, I am running an Exchange 2003 server using Outlook 2003 clients. What I am needing is code that will run when a specific sender sends an email to me with a specific (text) in the body of the email. I then want it forward/email to an outside email recipient. I am aware that you can activate automatic email forwarding in the Exchange server, however I view this as a major security risk. Any assistance would be greatly welcomed |
#4
|
|||
|
|||
![]()
In that case handle either the NewMailEx event or the Item.Add event on the
Items collection of the Inbox. If you handle NewMailEx then you'd get a string of all the EntryID's of the incoming items, separated by commas. You can use the Split function to split those into an array of EntryID's. Use NameSpace.GetItemFromID with each EntryID to get the item, then use string functions to parse the Body looking for your catch phrase. Also check for SenderName and/or SenderEmailAddress to see who sent the item to you. Then use the Forward method to send the item wherever you want. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "TerryM" wrote in message ... What you wrote is totally true except for the fact that Exchange by default disables automatic forwarding to external sources. That is the reason why I was wanting code to basically take the email with the specific sender and text in the body and automatically create a new email and send it out. This way Exchange doesn't view it as a forward to an outside location. You can manually send to outside locations, however you can't automatically forward emails to outside locations without enabling this function. And that security wise is something I do not want to do. |
#5
|
|||
|
|||
![]()
That's more of what I was looking for, but like I stated before. I'm
relatively new to VBA programming especially in Outlook. Were more of a Delphi place, what would the code that I'm requiring look like? "Ken Slovak - [MVP - Outlook]" wrote: In that case handle either the NewMailEx event or the Item.Add event on the Items collection of the Inbox. If you handle NewMailEx then you'd get a string of all the EntryID's of the incoming items, separated by commas. You can use the Split function to split those into an array of EntryID's. Use NameSpace.GetItemFromID with each EntryID to get the item, then use string functions to parse the Body looking for your catch phrase. Also check for SenderName and/or SenderEmailAddress to see who sent the item to you. Then use the Forward method to send the item wherever you want. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "TerryM" wrote in message ... What you wrote is totally true except for the fact that Exchange by default disables automatic forwarding to external sources. That is the reason why I was wanting code to basically take the email with the specific sender and text in the body and automatically create a new email and send it out. This way Exchange doesn't view it as a forward to an outside location. You can manually send to outside locations, however you can't automatically forward emails to outside locations without enabling this function. And that security wise is something I do not want to do. |
#6
|
|||
|
|||
![]()
Something like this, although this has no real error handling and needs to
be tweaked so there's no possibility of an endless loop. This code would go into the ThisOutlookSession class module in the Outlook VBA project. You would of course have to sign the project or lower macro security to have it run. Private Sub Application_NewMailEx(ByVal EntryIDCollection As String) Dim aID() As String Dim oMail As Outlook.MailItem Dim oFwd As Outlook.MailItem Dim oNS As Outlook.NameSpace Dim oRecip As Outlook.Recipient Dim obj As Object Dim i As Long Dim sBody As String Const SEARCH_FOR As String = "Foobar" Const SEARCH_ADDY As String = " Const FORWARD_TO As String = " Set oNS = Application.GetNamespace("MAPI") On Error Resume Next aID = Split(EntryIDCollection, ",") For i = LBound(aID) To UBound(aID) Set obj = oNS.GetItemFromID(aID(i)) If obj.Class = olMail Then Set oMail = obj sBody = oMail.Body If ((InStr(1, sBody, SEARCH_FOR, vbTextCompare) 0) And _ (oMail.SenderEmailAddress = SEARCH_ADDY)) Then Set oFwd = oMail.Forward Set oRecip = oFwd.Recipients.Add(FORWARD_TO) oRecip.Resolve If oRecip.Resolved Then oFwd.Send End If End If End If Set oMail = Nothing Set oFwd = Nothing Set oRecip = Nothing Set obj = Nothing Next Set oNS = Nothing End Sub -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "TerryM" wrote in message ... That's more of what I was looking for, but like I stated before. I'm relatively new to VBA programming especially in Outlook. Were more of a Delphi place, what would the code that I'm requiring look like? |
#8
|
|||
|
|||
![]()
Please do not hijack other people's threads. What you are asking has nothing
to do with this thread. If you want code to run obviously your computer must be running. You can use an ItemAdd() handler or a NewMailEx() handler in the Outlook VBA project and get the properties you want from the incoming item and use Application.CreateItem(olMail) to create a new email. You can then populate that item, say it's oMail as desired: oMail.Subject = "whatever", "), oMail.Body = "status=In Progress", etc. You can then call Send() on the item to send it out. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Tomas" wrote in message ... Hello Ken, may be you could help me with similar Issue i think i can not handle easily. I am not sure which way to go on incoming email and specific text in subject. i see i have two options. On incoming email with text in Subject either run script or make auto reply directly in outlook. What i am looking for is to take a piece subject of email i got and repost it. The incoming email subject looks like "Service call 10745707 has been assigned to you." What i would like to do is to reply to this emial like: _send to: _subject: update 10745707 _Body: status=In Progress I also though i could run a script on this like start application excel, data to columns and then the code for send email. Anyway this looks to me kinda to complicated and also when running this script my pc must be always on. Could you please help me with this issue? Thank you in advance Best regards Tomas |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
forwarding email ?? | Henry Kolesnik | Outlook Express | 4 | February 16th 07 01:16 PM |
Inserting contacts email address to send when forwarding email. | NeliRosi | Outlook - General Queries | 3 | August 10th 06 10:54 PM |
How do we ntegrate with email forwarding and email lists? | BrewsterR | Outlook - Using Forms | 1 | May 8th 06 03:34 PM |
Email editor closes when forwarding Excel-embedded email | Outlook - General Queries | 0 | March 18th 06 03:01 PM | |
Email editor closes when forwarding Excel-embedded email | Outlook - Installation | 0 | March 18th 06 03:01 PM |