![]() |
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 get confirmation for work via e-mail and want to automaticelly create an
appointment item from the mail. How can I get vba to read only a bit of the text in the subjectfield to get the right mail... the subjectfield always contain 3 words in the beginning that are the same for all i.e. "Confirmation from Company" + an address then I want to get the time and hour from a textstring in the body and also the address from another textstring in the body i.e. different lines. in addition I want all text exept for the 3 first lines of the mailbody to occur as bodytext in the appointment... somebody that can help? |
Ads |
#2
|
|||
|
|||
![]()
Thanks, this helped me a lot on my way, but raised a couple of other
question...... - if I have a string that looks like this : "Bekreftelse fra Visningsfilm - Oppdragsnr 8934005 Strandveien 34, 1440 Drøbak" (in norwegian) how can I get the last part of this string i.e Strandveien 34, 1440 Drøbak when the total length of the string changes... the numeric nr number can change with one or two chiffer, the same can the last part thats an address... is it possible to search for the third space or alternatively how can i get a string out of the body text thats like 12 lines down and 7 char + a tab in? and how can i get this to run whenever a new mail comes in the inbox....? i'm a real novice in programming, but trying to learn... lol "Eric Legault [MVP - Outlook]" wrote: In your VBA editor, display the Object Browser (F2), choose VBA from the top dropdown box and select the Strings class from the left pane. There are a variety of text functions you can use (especially InStr, Replace, Left, Mid, etc.) that can help you find certain text in the message body. Once you get the text you need, it's easy to create a new appointment item: Dim olApp As Outlook.Application Dim objAppt As Outlook.AppointmentItem Set olApp = Outlook.Application 'Create appointment item Set objAppt = olApp.CreateItem(olAppointmentItem) objAppt.Body = "My body text" -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: I get confirmation for work via e-mail and want to automaticelly create an appointment item from the mail. How can I get vba to read only a bit of the text in the subjectfield to get the right mail... the subjectfield always contain 3 words in the beginning that are the same for all i.e. "Confirmation from Company" + an address then I want to get the time and hour from a textstring in the body and also the address from another textstring in the body i.e. different lines. in addition I want all text exept for the 3 first lines of the mailbody to occur as bodytext in the appointment... somebody that can help? |
#3
|
|||
|
|||
![]()
If you know the starting point of where the text you want occurs, use InStr
to get the value for the number of characters into the complete text your specified text occurs. Then use that as the starting point for the parameter you pass to future InStr and Mid calls. This can be tricky, but unless you have full control over the format of the text you are getting, you're stuck. Otherwise, see if you can format this information in comma-delimited format, either in the body or separately in an attachment to the message. Another library that can help you is the Microsoft Scripting RunTime library. This has a TextStream object that allows for single line reads to narrow down the text you are working with. However, you'd have to save the e-mail to a file first. Automatically processing incoming e-mails can be a little challenging, but this article should send you on your way: Description of programming with Outlook rules: http://support.microsoft.com/?kbid=324568 -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: Thanks, this helped me a lot on my way, but raised a couple of other question...... - if I have a string that looks like this : "Bekreftelse fra Visningsfilm - Oppdragsnr 8934005 Strandveien 34, 1440 Drøbak" (in norwegian) how can I get the last part of this string i.e Strandveien 34, 1440 Drøbak when the total length of the string changes... the numeric nr number can change with one or two chiffer, the same can the last part thats an address... is it possible to search for the third space or alternatively how can i get a string out of the body text thats like 12 lines down and 7 char + a tab in? and how can i get this to run whenever a new mail comes in the inbox....? i'm a real novice in programming, but trying to learn... lol "Eric Legault [MVP - Outlook]" wrote: In your VBA editor, display the Object Browser (F2), choose VBA from the top dropdown box and select the Strings class from the left pane. There are a variety of text functions you can use (especially InStr, Replace, Left, Mid, etc.) that can help you find certain text in the message body. Once you get the text you need, it's easy to create a new appointment item: Dim olApp As Outlook.Application Dim objAppt As Outlook.AppointmentItem Set olApp = Outlook.Application 'Create appointment item Set objAppt = olApp.CreateItem(olAppointmentItem) objAppt.Body = "My body text" -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: I get confirmation for work via e-mail and want to automaticelly create an appointment item from the mail. How can I get vba to read only a bit of the text in the subjectfield to get the right mail... the subjectfield always contain 3 words in the beginning that are the same for all i.e. "Confirmation from Company" + an address then I want to get the time and hour from a textstring in the body and also the address from another textstring in the body i.e. different lines. in addition I want all text exept for the 3 first lines of the mailbody to occur as bodytext in the appointment... somebody that can help? |
#4
|
|||
|
|||
![]()
Thanks, I will Look into that...
but is it possible to use an seach inside a string or body text and get the startpoint for where the search find the word, and then use that startpoint to specify from where I want to get my text? because there will always be a spesific word before the the data I want to use... i.e. in the bodytext it will be a word like "address" and then a TAB or SPACE (Text created from a database) then there will be the data (textstring/address) that I want to use) Can you help me with a codesample that do this or something similar, because I can't get wildcard to work properly... Just find some exsamples in another thread that I will try out though... Actually I can't understand that nobody has needed this earlier.... lol... Thanks for all your help, the first response got me alot in the way... jaran "Eric Legault [MVP - Outlook]" wrote: If you know the starting point of where the text you want occurs, use InStr to get the value for the number of characters into the complete text your specified text occurs. Then use that as the starting point for the parameter you pass to future InStr and Mid calls. This can be tricky, but unless you have full control over the format of the text you are getting, you're stuck. Otherwise, see if you can format this information in comma-delimited format, either in the body or separately in an attachment to the message. Another library that can help you is the Microsoft Scripting RunTime library. This has a TextStream object that allows for single line reads to narrow down the text you are working with. However, you'd have to save the e-mail to a file first. Automatically processing incoming e-mails can be a little challenging, but this article should send you on your way: Description of programming with Outlook rules: http://support.microsoft.com/?kbid=324568 -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: Thanks, this helped me a lot on my way, but raised a couple of other question...... - if I have a string that looks like this : "Bekreftelse fra Visningsfilm - Oppdragsnr 8934005 Strandveien 34, 1440 Drøbak" (in norwegian) how can I get the last part of this string i.e Strandveien 34, 1440 Drøbak when the total length of the string changes... the numeric nr number can change with one or two chiffer, the same can the last part thats an address... is it possible to search for the third space or alternatively how can i get a string out of the body text thats like 12 lines down and 7 char + a tab in? and how can i get this to run whenever a new mail comes in the inbox....? i'm a real novice in programming, but trying to learn... lol "Eric Legault [MVP - Outlook]" wrote: In your VBA editor, display the Object Browser (F2), choose VBA from the top dropdown box and select the Strings class from the left pane. There are a variety of text functions you can use (especially InStr, Replace, Left, Mid, etc.) that can help you find certain text in the message body. Once you get the text you need, it's easy to create a new appointment item: Dim olApp As Outlook.Application Dim objAppt As Outlook.AppointmentItem Set olApp = Outlook.Application 'Create appointment item Set objAppt = olApp.CreateItem(olAppointmentItem) objAppt.Body = "My body text" -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: I get confirmation for work via e-mail and want to automaticelly create an appointment item from the mail. How can I get vba to read only a bit of the text in the subjectfield to get the right mail... the subjectfield always contain 3 words in the beginning that are the same for all i.e. "Confirmation from Company" + an address then I want to get the time and hour from a textstring in the body and also the address from another textstring in the body i.e. different lines. in addition I want all text exept for the 3 first lines of the mailbody to occur as bodytext in the appointment... somebody that can help? |
#5
|
|||
|
|||
![]()
Actually, I just found out that all the information are in an html tabel, is
it some way to get fields properties i.e. as in word or excel? how does I get the tabel info? "Eric Legault [MVP - Outlook]" wrote: If you know the starting point of where the text you want occurs, use InStr to get the value for the number of characters into the complete text your specified text occurs. Then use that as the starting point for the parameter you pass to future InStr and Mid calls. This can be tricky, but unless you have full control over the format of the text you are getting, you're stuck. Otherwise, see if you can format this information in comma-delimited format, either in the body or separately in an attachment to the message. Another library that can help you is the Microsoft Scripting RunTime library. This has a TextStream object that allows for single line reads to narrow down the text you are working with. However, you'd have to save the e-mail to a file first. Automatically processing incoming e-mails can be a little challenging, but this article should send you on your way: Description of programming with Outlook rules: http://support.microsoft.com/?kbid=324568 -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: Thanks, this helped me a lot on my way, but raised a couple of other question...... - if I have a string that looks like this : "Bekreftelse fra Visningsfilm - Oppdragsnr 8934005 Strandveien 34, 1440 Drøbak" (in norwegian) how can I get the last part of this string i.e Strandveien 34, 1440 Drøbak when the total length of the string changes... the numeric nr number can change with one or two chiffer, the same can the last part thats an address... is it possible to search for the third space or alternatively how can i get a string out of the body text thats like 12 lines down and 7 char + a tab in? and how can i get this to run whenever a new mail comes in the inbox....? i'm a real novice in programming, but trying to learn... lol "Eric Legault [MVP - Outlook]" wrote: In your VBA editor, display the Object Browser (F2), choose VBA from the top dropdown box and select the Strings class from the left pane. There are a variety of text functions you can use (especially InStr, Replace, Left, Mid, etc.) that can help you find certain text in the message body. Once you get the text you need, it's easy to create a new appointment item: Dim olApp As Outlook.Application Dim objAppt As Outlook.AppointmentItem Set olApp = Outlook.Application 'Create appointment item Set objAppt = olApp.CreateItem(olAppointmentItem) objAppt.Body = "My body text" -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: I get confirmation for work via e-mail and want to automaticelly create an appointment item from the mail. How can I get vba to read only a bit of the text in the subjectfield to get the right mail... the subjectfield always contain 3 words in the beginning that are the same for all i.e. "Confirmation from Company" + an address then I want to get the time and hour from a textstring in the body and also the address from another textstring in the body i.e. different lines. in addition I want all text exept for the 3 first lines of the mailbody to occur as bodytext in the appointment... somebody that can help? |
#6
|
|||
|
|||
![]()
If you know that the text you want will be inside a specific cell in an HTML
table, then you can use the MSHTML.HTMLDocument library. This example just illustrates how to get at the full HTML using that library: Sub Test() Dim i 'As Integer Dim strHTMLType 'As String Dim strHTMLText 'As String Dim NL 'As String Dim myInspector As Object Dim myIExplorer As Object NL = Chr(10) & Chr(13) Set myInspector = ActiveInspector Set myIExplorer = myInspector.HTMLEditor If myIExplorer.ReadyState = "complete" Then 'Test for complete loading of HTML doc For i = 0 To myIExplorer.All.Length - 1 strHTMLType = TypeName(myIExplorer.All.Item(i)) On Error Resume Next 'because not all elements support OuterHTML strHTMLText = ": " & NL & myIExplorer.All.Item(i).outerHTML On Error GoTo 0 MsgBox strHTMLType & strHTMLText strHTMLText = "" Next End If End Sub But programming with the HTMLDocument object is outside of Outlook's scope. There are ways to get the text you want though; this may be of some help, but the example is with javascript: Using the TextRange Object: http://msdn.microsoft.com/workshop/a...asp?frame=true Otherwise, my other reply explained how to use a word to get the starting point. Here's an example: 'return the character position of "My text" in the e-mail: intX = Instr(objMailItem.Body, "My text") 'continues to find "more text" after "My text" intX = Instr(intX, objMailItem.Body, "more text" -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: Actually, I just found out that all the information are in an html tabel, is it some way to get fields properties i.e. as in word or excel? how does I get the tabel info? "Eric Legault [MVP - Outlook]" wrote: If you know the starting point of where the text you want occurs, use InStr to get the value for the number of characters into the complete text your specified text occurs. Then use that as the starting point for the parameter you pass to future InStr and Mid calls. This can be tricky, but unless you have full control over the format of the text you are getting, you're stuck. Otherwise, see if you can format this information in comma-delimited format, either in the body or separately in an attachment to the message. Another library that can help you is the Microsoft Scripting RunTime library. This has a TextStream object that allows for single line reads to narrow down the text you are working with. However, you'd have to save the e-mail to a file first. Automatically processing incoming e-mails can be a little challenging, but this article should send you on your way: Description of programming with Outlook rules: http://support.microsoft.com/?kbid=324568 -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: Thanks, this helped me a lot on my way, but raised a couple of other question...... - if I have a string that looks like this : "Bekreftelse fra Visningsfilm - Oppdragsnr 8934005 Strandveien 34, 1440 Drøbak" (in norwegian) how can I get the last part of this string i.e Strandveien 34, 1440 Drøbak when the total length of the string changes... the numeric nr number can change with one or two chiffer, the same can the last part thats an address... is it possible to search for the third space or alternatively how can i get a string out of the body text thats like 12 lines down and 7 char + a tab in? and how can i get this to run whenever a new mail comes in the inbox....? i'm a real novice in programming, but trying to learn... lol "Eric Legault [MVP - Outlook]" wrote: In your VBA editor, display the Object Browser (F2), choose VBA from the top dropdown box and select the Strings class from the left pane. There are a variety of text functions you can use (especially InStr, Replace, Left, Mid, etc.) that can help you find certain text in the message body. Once you get the text you need, it's easy to create a new appointment item: Dim olApp As Outlook.Application Dim objAppt As Outlook.AppointmentItem Set olApp = Outlook.Application 'Create appointment item Set objAppt = olApp.CreateItem(olAppointmentItem) objAppt.Body = "My body text" -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: I get confirmation for work via e-mail and want to automaticelly create an appointment item from the mail. How can I get vba to read only a bit of the text in the subjectfield to get the right mail... the subjectfield always contain 3 words in the beginning that are the same for all i.e. "Confirmation from Company" + an address then I want to get the time and hour from a textstring in the body and also the address from another textstring in the body i.e. different lines. in addition I want all text exept for the 3 first lines of the mailbody to occur as bodytext in the appointment... somebody that can help? |
#7
|
|||
|
|||
![]()
Thank you
I have a macro that get the info I want, only thing left are to get it running on incomming mail... You have really helped me out best regards jaran "Eric Legault [MVP - Outlook]" wrote: If you know that the text you want will be inside a specific cell in an HTML table, then you can use the MSHTML.HTMLDocument library. This example just illustrates how to get at the full HTML using that library: Sub Test() Dim i 'As Integer Dim strHTMLType 'As String Dim strHTMLText 'As String Dim NL 'As String Dim myInspector As Object Dim myIExplorer As Object NL = Chr(10) & Chr(13) Set myInspector = ActiveInspector Set myIExplorer = myInspector.HTMLEditor If myIExplorer.ReadyState = "complete" Then 'Test for complete loading of HTML doc For i = 0 To myIExplorer.All.Length - 1 strHTMLType = TypeName(myIExplorer.All.Item(i)) On Error Resume Next 'because not all elements support OuterHTML strHTMLText = ": " & NL & myIExplorer.All.Item(i).outerHTML On Error GoTo 0 MsgBox strHTMLType & strHTMLText strHTMLText = "" Next End If End Sub But programming with the HTMLDocument object is outside of Outlook's scope. There are ways to get the text you want though; this may be of some help, but the example is with javascript: Using the TextRange Object: http://msdn.microsoft.com/workshop/a...asp?frame=true Otherwise, my other reply explained how to use a word to get the starting point. Here's an example: 'return the character position of "My text" in the e-mail: intX = Instr(objMailItem.Body, "My text") 'continues to find "more text" after "My text" intX = Instr(intX, objMailItem.Body, "more text" -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: Actually, I just found out that all the information are in an html tabel, is it some way to get fields properties i.e. as in word or excel? how does I get the tabel info? "Eric Legault [MVP - Outlook]" wrote: If you know the starting point of where the text you want occurs, use InStr to get the value for the number of characters into the complete text your specified text occurs. Then use that as the starting point for the parameter you pass to future InStr and Mid calls. This can be tricky, but unless you have full control over the format of the text you are getting, you're stuck. Otherwise, see if you can format this information in comma-delimited format, either in the body or separately in an attachment to the message. Another library that can help you is the Microsoft Scripting RunTime library. This has a TextStream object that allows for single line reads to narrow down the text you are working with. However, you'd have to save the e-mail to a file first. Automatically processing incoming e-mails can be a little challenging, but this article should send you on your way: Description of programming with Outlook rules: http://support.microsoft.com/?kbid=324568 -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: Thanks, this helped me a lot on my way, but raised a couple of other question...... - if I have a string that looks like this : "Bekreftelse fra Visningsfilm - Oppdragsnr 8934005 Strandveien 34, 1440 Drøbak" (in norwegian) how can I get the last part of this string i.e Strandveien 34, 1440 Drøbak when the total length of the string changes... the numeric nr number can change with one or two chiffer, the same can the last part thats an address... is it possible to search for the third space or alternatively how can i get a string out of the body text thats like 12 lines down and 7 char + a tab in? and how can i get this to run whenever a new mail comes in the inbox....? i'm a real novice in programming, but trying to learn... lol "Eric Legault [MVP - Outlook]" wrote: In your VBA editor, display the Object Browser (F2), choose VBA from the top dropdown box and select the Strings class from the left pane. There are a variety of text functions you can use (especially InStr, Replace, Left, Mid, etc.) that can help you find certain text in the message body. Once you get the text you need, it's easy to create a new appointment item: Dim olApp As Outlook.Application Dim objAppt As Outlook.AppointmentItem Set olApp = Outlook.Application 'Create appointment item Set objAppt = olApp.CreateItem(olAppointmentItem) objAppt.Body = "My body text" -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "StoltHD" wrote: I get confirmation for work via e-mail and want to automaticelly create an appointment item from the mail. How can I get vba to read only a bit of the text in the subjectfield to get the right mail... the subjectfield always contain 3 words in the beginning that are the same for all i.e. "Confirmation from Company" + an address then I want to get the time and hour from a textstring in the body and also the address from another textstring in the body i.e. different lines. in addition I want all text exept for the 3 first lines of the mailbody to occur as bodytext in the appointment... somebody that can help? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How can I create a outlook appointment item from data in a e-mail? | Eric Legault [MVP - Outlook] | Outlook and VBA | 0 | June 15th 06 07:23 PM |
Cannot Create New Data File | Bill Byrnes | Outlook - General Queries | 0 | June 14th 06 03:19 AM |
Create shortcut for File-Open-Outlook Data | larjo42 | Outlook and VBA | 0 | May 23rd 06 03:34 PM |
Can't double click to create a new appointment in Outlook | pts66 | Outlook - Calandaring | 1 | March 2nd 06 07:43 PM |
Create a new item | jim | Add-ins for Outlook | 3 | February 8th 06 03:16 PM |