How can I create a outlook appointment item from data in a e-mail?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
 
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/
 
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
 
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?
 
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/
 
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
 
Back
Top