Importing Task

Status
Not open for further replies.
B

Bre-x

Hi,

I have a function on MS Access to export data into outlook

I would like to move to MS Outlook, so that I can importa data

Could you help me to modify it?

Function send_data()

Dim olApp As Outlook.Application

Dim Tsk As Outlook.TaskItem

Dim rst As Recordset

On Error Resume Next

Set olApp = New Outlook.Application

Set rst = CurrentDb.OpenRecordset("SELECT QIT_Tasks.* FROM QIT_Tasks;")

rst.MoveFirst

Do While Not rst.EOF

Set Tsk = olApp.CreateItem(olTaskItem)

With olApp.Application

'---------Tsk.Subject = rst!tasksubject

Tsk.DueDate = "07/14/2009"

Tsk.Categories = "My Category - Test "

Tsk.Body = "This is the Body - Test" & Chr(10) & "Line 02 -

Test"

Tsk.ReminderTime = "07/13/2009 10:30 AM"

Tsk.ReminderSet = True

Tsk.UnRead = True

Tsk.Save

'---------DoCmd.SetWarnings False

DoCmd.RunSQL "UPDATE IT_Tasks SET status = -1 WHERE

task_id=" & rst!task_id

DoCmd.SetWarnings True

End With

rst.MoveNext

Loop

rst.Close

Set Tsk = Nothing

Set olApp = Nothing

End Function
 
This demonstrates how to import contacts. That should be helpful for you:

http://www.vboffice.net/en/developers/copy-contacts-from-access-to-outlook

Best regards

Michael Bauer

Am Tue, 28 Jul 2009 13:49:29 -0600 schrieb Bre-x:


> Hi,

> I have a function on MS Access to export data into outlook
> I would like to move to MS Outlook, so that I can importa data

> Could you help me to modify it?

> Function send_data()
> Dim olApp As Outlook.Application
> Dim Tsk As Outlook.TaskItem
> Dim rst As Recordset

> On Error Resume Next

> Set olApp = New Outlook.Application

> Set rst = CurrentDb.OpenRecordset("SELECT QIT_Tasks.* FROM


QIT_Tasks;")
> rst.MoveFirst
> Do While Not rst.EOF
> Set Tsk = olApp.CreateItem(olTaskItem)
> With olApp.Application
> '---------------------------------------> Tsk.Subject = rst!tasksubject
> Tsk.DueDate = "07/14/2009"
> Tsk.Categories = "My Category - Test "
> Tsk.Body = "This is the Body - Test" & Chr(10) & "Line 02


-
> Test"
> Tsk.ReminderTime = "07/13/2009 10:30 AM"
> Tsk.ReminderSet = True
> Tsk.UnRead = True
> Tsk.Save
> '---------> DoCmd.SetWarnings False
> DoCmd.RunSQL "UPDATE IT_Tasks SET status = -1 WHERE
> task_id=" & rst!task_id
> DoCmd.SetWarnings True
> End With

> rst.MoveNext
> Loop
> rst.Close

> Set Tsk = Nothing
> Set olApp = Nothing

> End Function
 
Michael,

Thank you for answering my post

I have modified it, but it gives me an error

Sub Import_Tasks()

'Dim Variables

Dim olApp As Outlook.Application

Dim Tsk As Outlook.TaskItem

Dim var_fields As ADODB.Fields

'OPEN CONNECTION

ConnectDB

Set var_fields = m_Rs.var_fields 'HERE IS THE ERROR (Error: Object

required)

While Not m_Rs.EOF

With olApp.Application

Tsk.Subject = var_fields("tasksubject").Value

Tsk.DueDate = "07/29/2009"

Tsk.Categories = "My Category - Test "

Tsk.Body = "This is the Body - Test" & Chr(10) & "Line 02 - test "

Tsk.ReminderTime = "07/29/2009 10:30 AM"

Tsk.ReminderSet = True

Tsk.UnRead = True

Tsk.Save

End With

m_Rs.MoveNext

Wend

'CLOSE

m_Rs.Clone: Set m_Rs = Nothing

m_Cn.Close: Set m_Cn = Nothing

End Sub

Private Sub ConnectDB()

Dim var_file As String

Dim var_table As String

Dim var_fields As String

var_file = "E:\Programing\MSACCESS\Outlook_VBA\it_tasks.mdb"

var_table = "QIT_Tasks"

var_fields = "tasksubject, task_id"

Set m_Cn = New ADODB.Connection

With m_Cn

> Provider = "Microsoft.Jet.OLEDB.4.0"

> ConnectionString = var_file

> CursorLocation = adUseClient

> Mode = adModeShareDenyNone

> Open

End With

Set m_Rs = New ADODB.Recordset

With m_Rs

> CursorLocation = adUseClient

> CursorType = adOpenStatic

> LockType = adLockOptimistic

Set .ActiveConnection = m_Cn

> Open ("SELECT " & var_fields & " FROM " & var_table)

End With

End Sub

"Michael Bauer " <mb@mvps.org> wrote in message

news:drevbiqzqxje.16hosddhqmplo$.dlg@40tude.net...

> This demonstrates how to import contacts. That should be helpful for you:
> http://www.vboffice.net/en/developers/copy-contacts-from-access-to-outlook

> > Best regards
> Michael Bauer

> >

> Am Tue, 28 Jul 2009 13:49:29 -0600 schrieb Bre-x:
>
> > Hi,
>

>> I have a function on MS Access to export data into outlook
> > I would like to move to MS Outlook, so that I can importa data
>

>> Could you help me to modify it?
>

>
>> Function send_data()
> > Dim olApp As Outlook.Application
> > Dim Tsk As Outlook.TaskItem
> > Dim rst As Recordset
>

>> On Error Resume Next
>

>> Set olApp = New Outlook.Application
>

>> Set rst = CurrentDb.OpenRecordset("SELECT QIT_Tasks.* FROM

> QIT_Tasks;")
> > rst.MoveFirst
> > Do While Not rst.EOF
> > Set Tsk = olApp.CreateItem(olTaskItem)
> > With olApp.Application
> > '---------------------------------------> > Tsk.Subject = rst!tasksubject
> > Tsk.DueDate = "07/14/2009"
> > Tsk.Categories = "My Category - Test "
> > Tsk.Body = "This is the Body - Test" & Chr(10) & "Line 02

> -
> > Test"
> > Tsk.ReminderTime = "07/13/2009 10:30 AM"
> > Tsk.ReminderSet = True
> > Tsk.UnRead = True
> > Tsk.Save
> > '--------------------------------------->

>> DoCmd.SetWarnings False
> > DoCmd.RunSQL "UPDATE IT_Tasks SET status = -1 WHERE
> > task_id=" & rst!task_id
> > DoCmd.SetWarnings True
> > End With
>

>> rst.MoveNext
> > Loop
> > rst.Close
>

>> Set Tsk = Nothing
> > Set olApp = Nothing
>

>> End Function
 
I'm sorry, that's my fault. On the module level you need to declare the

variables:

Private m_Rs as Adodb.Recordset

Private m_Cn as Adodb.Connection

Best regards

Michael Bauer

Am Wed, 29 Jul 2009 14:14:28 -0600 schrieb Bre-x:


> Michael,

> Thank you for answering my post
> I have modified it, but it gives me an error

> Sub Import_Tasks()
> 'Dim Variables
> Dim olApp As Outlook.Application
> Dim Tsk As Outlook.TaskItem
> Dim var_fields As ADODB.Fields

> 'OPEN CONNECTION
> ConnectDB
> Set var_fields = m_Rs.var_fields 'HERE IS THE ERROR (Error: Object
> required)

> While Not m_Rs.EOF
> With olApp.Application
> Tsk.Subject = var_fields("tasksubject").Value
> Tsk.DueDate = "07/29/2009"
> Tsk.Categories = "My Category - Test "
> Tsk.Body = "This is the Body - Test" & Chr(10) & "Line 02 - test "
> Tsk.ReminderTime = "07/29/2009 10:30 AM"
> Tsk.ReminderSet = True
> Tsk.UnRead = True
> Tsk.Save
> End With
> m_Rs.MoveNext
> Wend

> 'CLOSE
> m_Rs.Clone: Set m_Rs = Nothing
> m_Cn.Close: Set m_Cn = Nothing
> End Sub

> Private Sub ConnectDB()
> Dim var_file As String
> Dim var_table As String
> Dim var_fields As String

> var_file = "E:\Programing\MSACCESS\Outlook_VBA\it_tasks.mdb"
> var_table = "QIT_Tasks"
> var_fields = "tasksubject, task_id"

> Set m_Cn = New ADODB.Connection
> With m_Cn
> .Provider = "Microsoft.Jet.OLEDB.4.0"
> .ConnectionString = var_file
> .CursorLocation = adUseClient
> .Mode = adModeShareDenyNone
> .Open
> End With

> Set m_Rs = New ADODB.Recordset
> With m_Rs
> .CursorLocation = adUseClient
> .CursorType = adOpenStatic
> .LockType = adLockOptimistic
> Set .ActiveConnection = m_Cn
> .Open ("SELECT " & var_fields & " FROM " & var_table)
> End With
> End Sub

> "Michael Bauer " <mb@mvps.org> wrote in message
> news:drevbiqzqxje.16hosddhqmplo$.dlg@40tude.net...
>

>
>> This demonstrates how to import contacts. That should be helpful for you:
> >


http://www.vboffice.net/en/developers/copy-contacts-from-access-to-outlook
>

>> > > Best regards
> > Michael Bauer
>

>> >> >
>
>> Am Tue, 28 Jul 2009 13:49:29 -0600 schrieb Bre-x:
> >
> >> Hi,
> >
>>> I have a function on MS Access to export data into outlook
> >> I would like to move to MS Outlook, so that I can importa data
> >
>>> Could you help me to modify it?
> >
>>
>>> Function send_data()
> >> Dim olApp As Outlook.Application
> >> Dim Tsk As Outlook.TaskItem
> >> Dim rst As Recordset
> >
>>> On Error Resume Next
> >
>>> Set olApp = New Outlook.Application
> >
>>> Set rst = CurrentDb.OpenRecordset("SELECT QIT_Tasks.* FROM

> > QIT_Tasks;")
> >> rst.MoveFirst
> >> Do While Not rst.EOF
> >> Set Tsk = olApp.CreateItem(olTaskItem)
> >> With olApp.Application
> >> '---------------------------------------> >> Tsk.Subject = rst!tasksubject
> >> Tsk.DueDate = "07/14/2009"
> >> Tsk.Categories = "My Category - Test "
> >> Tsk.Body = "This is the Body - Test" & Chr(10) & "Line


02
> > -
> >> Test"
> >> Tsk.ReminderTime = "07/13/2009 10:30 AM"
> >> Tsk.ReminderSet = True
> >> Tsk.UnRead = True
> >> Tsk.Save
> >> '---------------------------------------> >
>>> DoCmd.SetWarnings False
> >> DoCmd.RunSQL "UPDATE IT_Tasks SET status = -1 WHERE
> >> task_id=" & rst!task_id
> >> DoCmd.SetWarnings True
> >> End With
> >
>>> rst.MoveNext
> >> Loop
> >> rst.Close
> >
>>> Set Tsk = Nothing
> >> Set olApp = Nothing
> >
>>> End Function
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
HarvMan Importing PST into IMAP account Using Outlook 12
CWM330 Importing " Old Skool" Data Using Outlook 0
P Importing other e-mail accounts into Outlook Using Outlook 1
M How to setup outlook after importing old account information - Entering email account info creates with "(1)" after the account! Using Outlook 1
J Importing N2K from a different Exchange Server Using Outlook 1
J Outlook 2010 Changing events in Outlook calendar via opening file, importing CSV Using Outlook 0
O Importing Mbox - anyone out there having experience with this tool... Using Outlook 2
D Importing Outlook Categories from another domain (Exchange 2016/Outlook 2016) Using Outlook 4
B Importing business card into Outlook for SIgnature Using Outlook 1
S Importing Ribbons Not Saved Using Outlook 7
V importing appointments to non-default calendar? Using Outlook 1
Diane Poremsky Importing Lists from Excel to Outlook Using Outlook 0
B Importing Text from Excel to Outlook 2013 Calender Using Outlook 0
CWM330 Importing from Eudora Update Using Outlook 5
CWM330 Importing from Eudora Using Outlook 7
N Importing Google contacts from CSV file removes recipient names in autocomplete list Using Outlook 0
S Importing emails to contacts Using Outlook 3
Z Importing PST files from Outlook 07 to Outlook mac Preview Using Outlook 1
Z how to make OL (2007) to use custom contact form when importing / opening .VCF? Using Outlook 1
P Importing Thunderbird email to outlook Using Outlook 2
K Importing appointment body from excel in outlook 2010 Using Outlook 1
A Importing too many emails from Gmail Using Outlook 2
J Importing to the correct calendar from Excel 2010 to Outlook 2010 Outlook VBA and Custom Forms 2
S Possible to link to ics file without importing? Using Outlook 4
L Importing Opportunities in to BCM 2013 BCM (Business Contact Manager) 0
K New to BCM - trouble importing contacts & accounts BCM (Business Contact Manager) 3
LarryH Importing csv file to custom form/fields? Using Outlook 3
T Importing Excel 2010 data into Outlook Calendar 2010 Using Outlook 12
W Importing .pst from Outlook 2010 (Win7) to Outlook 2013 (Win8.1) Using Outlook 2
V Importing Rules in Outlook 2013 Using Outlook 2
D Importing custom fields into custom form in BCM BCM (Business Contact Manager) 1
V Problem not having Contacts folder after importing emails from Yahoo. Using Outlook 0
O Importing contacts from CSV, comma delimited Using Outlook 7
B importing Outlook from a backup on an external hard drive Using Outlook 5
M Trouble Importing folders from Outlook 2007 to Outlook 2013 Using Outlook 12
wallisellener BCM 2013 importing contacts from CSV file BCM (Business Contact Manager) 8
T BCM not importing address BCM (Business Contact Manager) 1
T Importing OE6 e-mail to Outlook via Store Folder Using Outlook 9
A Trouble importing data to radio buttons Business Contact Manager 2010 (BCM) Using Outlook 2
H Importing Windows Live Mail Contact into Outlook 2010 Using Outlook 0
T Limit on importing Inbox mail from OE6 Using Outlook 16
Commodore Importing RSS on another computer (and feed locations) Using Outlook 8
M importing email address list from excel Using Outlook 6
O Importing pst, archive pst and address not working Using Outlook 17
N lose conditional formatting when importing to Outlook 2010 Using Outlook 2
C dates missing when importing emails Using Outlook 5
I Importing Outlook form into calendar folder? Using Outlook 1
R Exporting and importing contacts in Outlook 2007 Using Outlook 1
K Importing CSV contacts- doesnt allow me to map or move forward V 2007 Using Outlook 1
G Importing Excel contact data base into Outlook Using Outlook 1

Similar threads

Back
Top