RE: How can I create a outlook appointment item from data in a e-m
- From: StoltHD <StoltHD@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 17 Jun 2006 00:00:02 -0700
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/author/dyncontent/textrange.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?
- References:
- RE: How can I create a outlook appointment item from data in a e-m
- From: Eric Legault [MVP - Outlook]
- RE: How can I create a outlook appointment item from data in a e-m
- From: StoltHD
- RE: How can I create a outlook appointment item from data in a e-m
- From: Eric Legault [MVP - Outlook]
- RE: How can I create a outlook appointment item from data in a e-m
- Prev by Date: Re: Find......FindNext
- Next by Date: Re: Moving mail items into an "Archive" folder
- Previous by thread: RE: How can I create a outlook appointment item from data in a e-m
- Next by thread: Delete or Disable pop3 account
- Index(es):
Relevant Pages
|