- Sub ReadFile()
- Dim fs As Object
- Dim f As Object
- Dim a As Variant
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set f = fs.OpenTextFile("C:\Docs\Tasks.txt", 1) '1=for reading
- Do While f.AtEndOfStream = False
- a = Split(f.ReadLine, "|")
- CreateTask a(0), a(1), a(2), Now
- Loop
- End Sub
- Sub CreateTask(AssignToEmail, TaskSubject, TaskBody, TaskDateTime)
- Dim oTask As Outlook.TaskItem
- Dim AssignedTo As Outlook.Recipient
- Dim oNS As Outlook.NameSpace
- Set oTask = CreateItem(olTaskItem)
- oTask.Assign
- Set AssignedTo = oTask.Recipients.Add(AssignToEmail)
- oTask.Subject = TaskSubject
- oTask.Body = TaskBody
- oTask.DueDate = TaskDateTime
- oTask.Importance = 2 'olImportanceHigh
- oTask.ReminderSet = True
- 'oTask.Save
- 'Pick Display or Send
- oTask.Display
- 'OutlookTask.Send
- 'Clean up
- Set oTask = Nothing
- End Sub
Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary.
Forum Search
Forum Statistics
UsersTotal Post History
- Posts:
- 81456
- Topics:
- 18718
7-Day Post History
- New Posts:
- 0
- New Topics:
- 0
- Active Topics:
- 0
Our newest member
Other
-
FAQ
All times are UTC [ DST ]
Read file & create a new task by outlook vba
8 posts • Page 1 of 1
Please wait...
Read file & create a new task by outlook vba
I have never done any programing with outlook.
I want to read a file (text/ini/csv/xml) from outlook vba and add those details to a new task.
I have a simple exe located in the common server that is being used for maintenance & other service requests.
Not all the users have outlook.
The exe creates a file (now it is xml) of their requests. I want my program to read each one of them(on a specified interval) and add it to my outlook.
I am having vb.net exe that doing the job, takes a lot of memory. I thought it will be better to use something within outlook that is always open.
I want to read a file (text/ini/csv/xml) from outlook vba and add those details to a new task.
I have a simple exe located in the common server that is being used for maintenance & other service requests.
Not all the users have outlook.
The exe creates a file (now it is xml) of their requests. I want my program to read each one of them(on a specified interval) and add it to my outlook.
I am having vb.net exe that doing the job, takes a lot of memory. I thought it will be better to use something within outlook that is always open.
Zameer Abdulla
-
ZmrAbdulla - LTD Senior Moderator
-
- Posts: 225
- Joined: Thu Oct 18, 2007 7:43 am
- Location: United Arab Emirates
Re: Read file & create a new task by outlook vba
I am not sure where you are getting stuck, so here are a few notes.
Stop quoting laws to us. We carry swords.
-
Remou - LTD Admin
-
- Posts: 5414
- Joined: Sun Oct 14, 2007 11:26 am
Re: Read file & create a new task by outlook vba
Thanks Remou,
I am sure there is no timer in vba / userforms.
Do you suggest Sleep() for this purpose
Or anything else out there?
I want this code to run for the first time open outlook & every hour from then until outlook is closed.
I am sure there is no timer in vba / userforms.
Do you suggest Sleep() for this purpose
- Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Or anything else out there?
I want this code to run for the first time open outlook & every hour from then until outlook is closed.
Zameer Abdulla
-
ZmrAbdulla - LTD Senior Moderator
-
- Posts: 225
- Joined: Thu Oct 18, 2007 7:43 am
- Location: United Arab Emirates
Re: Read file & create a new task by outlook vba
I don't know what the ramifications of Sleep are on performance, but be aware there's SleepEx and WaitForSingleObject, which may give you more options...
God cries a little bit every time someone builds a database.
-
Emtucifor - Guru
-
- Posts: 2835
- Joined: Fri May 30, 2008 9:30 pm
- Location: Bellingham, WA
Re: Read file & create a new task by outlook vba
I am actually not interested to use API calls. Looking for a simple solution to replace the timer control.
And I don't know how to use(if possible) those C++ code in VBA.
And I don't know how to use(if possible) those C++ code in VBA.
Zameer Abdulla
-
ZmrAbdulla - LTD Senior Moderator
-
- Posts: 225
- Joined: Thu Oct 18, 2007 7:43 am
- Location: United Arab Emirates
Re: Read file & create a new task by outlook vba
I don't recall needing to "wait" in a real system, but for myself, I would generally use the system clock.
I have also seen:
I have also seen:
- Set WshShell = WScript.CreateObject("WScript.Shell")
- WScript.Sleep(600000)
Stop quoting laws to us. We carry swords.
-
Remou - LTD Admin
-
- Posts: 5414
- Joined: Sun Oct 14, 2007 11:26 am
Re: Read file & create a new task by outlook vba
I think it will not work in VBA. It gives me an error of Object Required.
Zameer Abdulla
-
ZmrAbdulla - LTD Senior Moderator
-
- Posts: 225
- Joined: Thu Oct 18, 2007 7:43 am
- Location: United Arab Emirates
Re: Read file & create a new task by outlook vba
Zameer Abdulla
-
ZmrAbdulla - LTD Senior Moderator
-
- Posts: 225
- Joined: Thu Oct 18, 2007 7:43 am
- Location: United Arab Emirates
8 posts • Page 1 of 1
LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.