View Single Post
  #3  
Old June 16th 06, 03:54 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default How can I create a outlook appointment item from data in a e-m

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?


Ads