Tasks - convert email to task & attach email

Status
Not open for further replies.
G

guiness_joe

Please find below code which converts email into a task, and pastes the email

text body into the task body and also pastes the email as attachment.

Problem:

1) the attached email is pasted at the end of the task body. I want it to be

pasted at the beginning of the task followed by the task body.

2) Can the task be automatically be saved into a personal folder?

3) Is there a way to autotype the categories list by typing the first few

letters?

4) Is there a way to auto fill calendar with the task items?

Public Sub AddCalendarEntry()

Const mailItem_c As String = "MailItem"

Dim OE As Outlook.Explorer ' olExp

Dim MI As Outlook.MailItem

Dim AI As Outlook.AppointmentItem

Dim TI As Outlook.TaskItem ' olTask

Dim olItem As Object

Set OE = Application.ActiveExplorer

'Abort sub if no item selected:

If OE.Selection.Count < 1 Then

MsgBox "Please select an already saved message before" & vbCrLf & _

"attempting to create an appointment or task" & vbCrLf & _

"with this button ...", vbInformation, "No message selected ..."

Exit Sub

'Abort sub if item selected is not a MailItem.

ElseIf TypeName(OE.Selection(1)) <> mailItem_c Then

MsgBox "You must select a mail item...", vbInformation, "Invalid

selection..."

Exit Sub

End If

Set MI = OE.Selection(1)

Beep

Select Case MsgBox("Is calendar entry an appointment?" & vbLf & _

"To Add Appointment (Yes) / To Add Task (No) / To Quit (Cancel)" & _

vbCrLf, vbYesNoCancel + vbQuestion, "Create an appointment or task

> ...")

Case vbYes 'If yes, create appointment

Set AI = Outlook.CreateItem(olAppointmentItem)

With AI

> Subject = MI.Subject

> Body = MI.Body

> Save

> Display

End With

Case vbNo

'If no, create task due with date of today

'and due date is tomorrow at 10:00 am

Set TI = Application.CreateItem(olTaskItem)

With TI

Dim cntSelection As Integer

cntSelection = OE.Selection.Count

For i = 1 To cntSelection

Set olItem = OE.Selection.Item(i)

TI.Attachments.Add olItem

Next

> Subject = MI.Subject

> Body = MI.Body

' .StartDate = Date

' .DueDate = Date + 1

' .ReminderTime = .DueDate & " 10:00"

> Save

> Display

End With

'Case vbCancel

' Exit Sub

End Select

End Sub
 
1) Outlook version?

2) Do you mean that you want to create a task in a folder other than your

default Tasks folder?

3) No.

4) Please explain what you mean by that.

Sue Mosher

"guiness_joe" <guiness_joe> wrote in message

news:11BE8E23-486D-424E-922A-545A4BA15AFF@microsoft.com...
> Please find below code which converts email into a task, and pastes the
> email
> text body into the task body and also pastes the email as attachment.

> Problem:

> 1) the attached email is pasted at the end of the task body. I want it to
> be
> pasted at the beginning of the task followed by the task body.
> 2) Can the task be automatically be saved into a personal folder?
> 3) Is there a way to autotype the categories list by typing the first few
> letters?
> 4) Is there a way to auto fill calendar with the task items?

> Public Sub AddCalendarEntry()
> Const mailItem_c As String = "MailItem"
> Dim OE As Outlook.Explorer ' olExp
> Dim MI As Outlook.MailItem
> Dim AI As Outlook.AppointmentItem
> Dim TI As Outlook.TaskItem ' olTask
> Dim olItem As Object

> Set OE = Application.ActiveExplorer

> 'Abort sub if no item selected:
> If OE.Selection.Count < 1 Then
> MsgBox "Please select an already saved message before" & vbCrLf & _
> "attempting to create an appointment or task" & vbCrLf & _
> "with this button ...", vbInformation, "No message selected ..."
> Exit Sub
> 'Abort sub if item selected is not a MailItem.
> ElseIf TypeName(OE.Selection(1)) <> mailItem_c Then
> MsgBox "You must select a mail item...", vbInformation, "Invalid
> selection..."
> Exit Sub
> End If

> Set MI = OE.Selection(1)
> Beep
> Select Case MsgBox("Is calendar entry an appointment?" & vbLf & _
> "To Add Appointment (Yes) / To Add Task (No) / To Quit (Cancel)" &
> _
> vbCrLf, vbYesNoCancel + vbQuestion, "Create an appointment or task
> ...")
> Case vbYes 'If yes, create appointment
> Set AI = Outlook.CreateItem(olAppointmentItem)
> With AI
> .Subject = MI.Subject

> .Body = MI.Body
> .Save
> .Display
> End With
> Case vbNo
> 'If no, create task due with date of today
> 'and due date is tomorrow at 10:00 am

> Set TI = Application.CreateItem(olTaskItem)

> With TI

> Dim cntSelection As Integer
> cntSelection = OE.Selection.Count

> For i = 1 To cntSelection

> Set olItem = OE.Selection.Item(i)
> TI.Attachments.Add olItem

> Next

> .Subject = MI.Subject
> .Body = MI.Body
> ' .StartDate = Date
> ' .DueDate = Date + 1
> ' .ReminderTime = .DueDate & " 10:00"
> .Save
> .Display

> End With

> 'Case vbCancel
> ' Exit Sub
> End Select
> End Sub
 
"Sue Mosher [MVP]" wrote:


> 1) Outlook version? 2003

> 2) Do you mean that you want to create a task in a folder other than your
> default Tasks folder? Yes, the below task after being created saves into a Personal folder.

> 3) No.

> 4) Please explain what you mean by that.


Can appointments be made of the Incomplete Task items that exist in the task

folder?

> > Sue Mosher
> > >

> "guiness_joe" <guiness_joe> wrote in message
> news:11BE8E23-486D-424E-922A-545A4BA15AFF@microsoft.com...
> > Please find below code which converts email into a task, and pastes the
> > email
> > text body into the task body and also pastes the email as attachment.
> > Problem:
> > 1) the attached email is pasted at the end of the task body. I want it to
> > be
> > pasted at the beginning of the task followed by the task body.
> > 2) Can the task be automatically be saved into a personal folder?
> > 3) Is there a way to autotype the categories list by typing the first few
> > letters?
> > 4) Is there a way to auto fill calendar with the task items?
> > Public Sub AddCalendarEntry()
> > Const mailItem_c As String = "MailItem"
> > Dim OE As Outlook.Explorer ' olExp
> > Dim MI As Outlook.MailItem
> > Dim AI As Outlook.AppointmentItem
> > Dim TI As Outlook.TaskItem ' olTask
> > Dim olItem As Object
> > Set OE = Application.ActiveExplorer
> > 'Abort sub if no item selected:
> > If OE.Selection.Count < 1 Then
> > MsgBox "Please select an already saved message before" & vbCrLf & _
> > "attempting to create an appointment or task" & vbCrLf & _
> > "with this button ...", vbInformation, "No message selected ..."
> > Exit Sub
> > 'Abort sub if item selected is not a MailItem.
> > ElseIf TypeName(OE.Selection(1)) <> mailItem_c Then
> > MsgBox "You must select a mail item...", vbInformation, "Invalid
> > selection..."
> > Exit Sub
> > End If
> > Set MI = OE.Selection(1)
> > Beep
> > Select Case MsgBox("Is calendar entry an appointment?" & vbLf & _
> > "To Add Appointment (Yes) / To Add Task (No) / To Quit (Cancel)" &
> > _
> > vbCrLf, vbYesNoCancel + vbQuestion, "Create an appointment or task
> > ...")
> > Case vbYes 'If yes, create appointment
> > Set AI = Outlook.CreateItem(olAppointmentItem)
> > With AI
> > .Subject = MI.Subject
> > .Body = MI.Body
> > .Save
> > .Display
> > End With
> > Case vbNo
> > 'If no, create task due with date of today
> > 'and due date is tomorrow at 10:00 am
> > Set TI = Application.CreateItem(olTaskItem)
> > With TI
> > Dim cntSelection As Integer
> > cntSelection = OE.Selection.Count
> > For i = 1 To cntSelection
> > Set olItem = OE.Selection.Item(i)
> > TI.Attachments.Add olItem
> > Next
> > .Subject = MI.Subject
> > .Body = MI.Body
> > ' .StartDate = Date
> > ' .DueDate = Date + 1
> > ' .ReminderTime = .DueDate & " 10:00"
> > .Save
> > .Display
> > End With
> > 'Case vbCancel
> > ' Exit Sub
> > End Select
> > End Sub


>
 
>> > 1) the attached email is pasted at the end of the task body. I want it
> > > to
> > > be
> > > pasted at the beginning of the task followed by the task body.


Since you're using Outlook 2003, you can handle this by using the third

parameter of the Attachments.Add method, which sets the position of the

attachment, e.g.:

TI.Attachments.Add olItem, olEmbeddeditem, 1


> > 2) Do you mean that you want to create a task in a folder other than your
> > default Tasks folder? Yes, the below task after being created saves into
> > a Personal folder.


"a Personal Folder" doesn't really answer the question, but let's assume you

wan to create a new item in a non-default folder. To do that, use the Add

method on the target folder's Items collection:

Set newItem = targetFolder.Items.Add("IPM.Task.YourFormName")

The message class parameter is optional.

To get a non-default folder, you need to walk the folder hierarchy using the

Folders collections or use a function that does that for you. For an

example, see:

http://www.outlookcode.com/codedetail.aspx?id=628 - uses a folder path

string


> Can appointments be made of the Incomplete Task items that exist in the
> task
> folder?


Yes, using the same technique that you're already using to create a task

create the task then assign values to its properties.

Sue Mosher

"guiness_joe" <guinessjoe> wrote in message

news:81A9DE04-8FD9-4DE9-BEC1-B0DE643E338F@microsoft.com...

> "Sue Mosher [MVP]" wrote:
>
> > 1) Outlook version? 2003
>

>> 2) Do you mean that you want to create a task in a folder other than your
> > default Tasks folder? Yes, the below task after being created saves into
> > a Personal folder.
>

>> 3) No.
>

>> 4) Please explain what you mean by that.

> Can appointments be made of the Incomplete Task items that exist in the
> task
> folder?
>

>> "guiness_joe" <guiness_joe> wrote in message
> > news:11BE8E23-486D-424E-922A-545A4BA15AFF@microsoft.com...
> > > Please find below code which converts email into a task, and pastes the
> > > email
> > > text body into the task body and also pastes the email as attachment.
> >> > Problem:
> >> > 1) the attached email is pasted at the end of the task body. I want it
> > > to
> > > be
> > > pasted at the beginning of the task followed by the task body.
> > > 2) Can the task be automatically be saved into a personal folder?
> > > 3) Is there a way to autotype the categories list by typing the first
> > > few
> > > letters?
> > > 4) Is there a way to auto fill calendar with the task items?
> >> > Public Sub AddCalendarEntry()
> > > Const mailItem_c As String = "MailItem"
> > > Dim OE As Outlook.Explorer ' olExp
> > > Dim MI As Outlook.MailItem
> > > Dim AI As Outlook.AppointmentItem
> > > Dim TI As Outlook.TaskItem ' olTask
> > > Dim olItem As Object
> >> > Set OE = Application.ActiveExplorer
> >> > 'Abort sub if no item selected:
> > > If OE.Selection.Count < 1 Then
> > > MsgBox "Please select an already saved message before" & vbCrLf
> > > & _
> > > "attempting to create an appointment or task" & vbCrLf & _
> > > "with this button ...", vbInformation, "No message selected ..."
> > > Exit Sub
> > > 'Abort sub if item selected is not a MailItem.
> > > ElseIf TypeName(OE.Selection(1)) <> mailItem_c Then
> > > MsgBox "You must select a mail item...", vbInformation, "Invalid
> > > selection..."
> > > Exit Sub
> > > End If
> >> > Set MI = OE.Selection(1)
> > > Beep
> > > Select Case MsgBox("Is calendar entry an appointment?" & vbLf & _
> > > "To Add Appointment (Yes) / To Add Task (No) / To Quit (Cancel)"
> > > &
> > > _
> > > vbCrLf, vbYesNoCancel + vbQuestion, "Create an appointment or
> > > task
> > > ...")
> > > Case vbYes 'If yes, create appointment
> > > Set AI = Outlook.CreateItem(olAppointmentItem)
> > > With AI
> > > .Subject = MI.Subject
> >> > .Body = MI.Body
> > > .Save
> > > .Display
> > > End With
> > > Case vbNo
> > > 'If no, create task due with date of today
> > > 'and due date is tomorrow at 10:00 am
> >> > Set TI = Application.CreateItem(olTaskItem)
> >> > With TI
> >> > Dim cntSelection As Integer
> > > cntSelection = OE.Selection.Count
> >> > For i = 1 To cntSelection
> >> > Set olItem = OE.Selection.Item(i)
> > > TI.Attachments.Add olItem
> >> > Next
> >> > .Subject = MI.Subject
> > > .Body = MI.Body
> > > ' .StartDate = Date
> > > ' .DueDate = Date + 1
> > > ' .ReminderTime = .DueDate & " 10:00"
> > > .Save
> > > .Display
> >> > End With
> >> > 'Case vbCancel
> > > ' Exit Sub
> > > End Select
> > > End Sub

>

>
>>
 
Thank you Sue!

1) TI.Attachments.Add olItem, olEmbeddeditem, 1

It attached an embedded picture of the email but not the email itself.

2) Your are right I have a personal folder which has Calendar and Task

inside it, which I wish to use. The Folder name is 01 Handover/Calendars, and

calendar folder name is Calendar and Task folder name is Task

5) If I create a couple of task form / templates, can I do all the previous

mentioned steps, i.e. paste email and email body at the end of the task

template body text? Also I want to have several Task forms / templates and

want to use one that suits the task function.

"Sue Mosher [MVP]" wrote:

1) the attached email is pasted at the end of the task body. I want it

be pasted at the beginning of the task followed by the task body.


> Since you're using Outlook 2003, you can handle this by using the third
> parameter of the Attachments.Add method, which sets the position of the
> attachment, e.g.:

> TI.Attachments.Add olItem, olEmbeddeditem, 1
>
> >> 2) Do you mean that you want to create a task in a folder other than your
> >> default Tasks folder? Yes, the below task after being created saves into
> >> a Personal folder.


> "a Personal Folder" doesn't really answer the question, but let's assume you
> wan to create a new item in a non-default folder. To do that, use the Add
> method on the target folder's Items collection:

> Set newItem = targetFolder.Items.Add("IPM.Task.YourFormName")

> The message class parameter is optional.

> To get a non-default folder, you need to walk the folder hierarchy using the
> Folders collections or use a function that does that for you. For an
> example, see:

> http://www.outlookcode.com/codedetail.aspx?id=628 - uses a folder path
> string
>
> > Can appointments be made of the Incomplete Task items that exist in the
> > task
> > folder?


> Yes, using the same technique that you're already using to create a task > create the task then assign values to its properties.

> > Sue Mosher
> > >

> "guiness_joe" <guinessjoe> wrote in message
> news:81A9DE04-8FD9-4DE9-BEC1-B0DE643E338F@microsoft.com...
> > "Sue Mosher [MVP]" wrote:
> >
> >> 1) Outlook version? 2003
> >
> >> 2) Do you mean that you want to create a task in a folder other than your
> >> default Tasks folder? Yes, the below task after being created saves into
> >> a Personal folder.
> >
> >> 3) No.
> >
> >> 4) Please explain what you mean by that.

> > Can appointments be made of the Incomplete Task items that exist in the
> > task
> > folder?
> >
> >> "guiness_joe" <guiness_joe> wrote in message
> >> news:11BE8E23-486D-424E-922A-545A4BA15AFF@microsoft.com...
> >> > Please find below code which converts email into a task, and pastes the
> >> > email
> >> > text body into the task body and also pastes the email as attachment.
> >> >> > Problem:
> >> >> > 1) the attached email is pasted at the end of the task body. I want it
> >> > to
> >> > be
> >> > pasted at the beginning of the task followed by the task body.
> >> > 2) Can the task be automatically be saved into a personal folder?
> >> > 3) Is there a way to autotype the categories list by typing the first
> >> > few
> >> > letters?
> >> > 4) Is there a way to auto fill calendar with the task items?
> >> >> > Public Sub AddCalendarEntry()
> >> > Const mailItem_c As String = "MailItem"
> >> > Dim OE As Outlook.Explorer ' olExp
> >> > Dim MI As Outlook.MailItem
> >> > Dim AI As Outlook.AppointmentItem
> >> > Dim TI As Outlook.TaskItem ' olTask
> >> > Dim olItem As Object
> >> >> > Set OE = Application.ActiveExplorer
> >> >> > 'Abort sub if no item selected:
> >> > If OE.Selection.Count < 1 Then
> >> > MsgBox "Please select an already saved message before" & vbCrLf
> >> > & _
> >> > "attempting to create an appointment or task" & vbCrLf & _
> >> > "with this button ...", vbInformation, "No message selected ..."
> >> > Exit Sub
> >> > 'Abort sub if item selected is not a MailItem.
> >> > ElseIf TypeName(OE.Selection(1)) <> mailItem_c Then
> >> > MsgBox "You must select a mail item...", vbInformation, "Invalid
> >> > selection..."
> >> > Exit Sub
> >> > End If
> >> >> > Set MI = OE.Selection(1)
> >> > Beep
> >> > Select Case MsgBox("Is calendar entry an appointment?" & vbLf & _
> >> > "To Add Appointment (Yes) / To Add Task (No) / To Quit (Cancel)"
> >> > &
> >> > _
> >> > vbCrLf, vbYesNoCancel + vbQuestion, "Create an appointment or
> >> > task
> >> > ...")
> >> > Case vbYes 'If yes, create appointment
> >> > Set AI = Outlook.CreateItem(olAppointmentItem)
> >> > With AI
> >> > .Subject = MI.Subject
> >> >> > .Body = MI.Body
> >> > .Save
> >> > .Display
> >> > End With
> >> > Case vbNo
> >> > 'If no, create task due with date of today
> >> > 'and due date is tomorrow at 10:00 am
> >> >> > Set TI = Application.CreateItem(olTaskItem)
> >> >> > With TI
> >> >> > Dim cntSelection As Integer
> >> > cntSelection = OE.Selection.Count
> >> >> > For i = 1 To cntSelection
> >> >> > Set olItem = OE.Selection.Item(i)
> >> > TI.Attachments.Add olItem
> >> >> > Next
> >> >> > .Subject = MI.Subject
> >> > .Body = MI.Body
> >> > ' .StartDate = Date
> >> > ' .DueDate = Date + 1
> >> > ' .ReminderTime = .DueDate & " 10:00"
> >> > .Save
> >> > .Display
> >> >> > End With
> >> >> > 'Case vbCancel
> >> > ' Exit Sub
> >> > End Select
> >> > End Sub
> >
> >
> >>


>
 
1) This is a task you're attaching to? Tasks don't handle embedded items

well, for reasons that have never been satisfactorily explained, IMO.

2) Then you need to follow the instructions I gave for using the Items.Add

method. You will not, however, be able to use the GetFolder() function,

because it assumes that there are no slashes in the folder name. Instead,

you'll need to start at the top of the folder hierarchy and walk down, using

the Folders collection of each MAPIFolder. If you need help with that, you

will need to give us the complete and exact path to the folder(s), starting

at the top of the hierarchy.

5) If you want to do all the same procedures in a custom form, then invoke

the custom form using the message class parameter in the Items.Add method.

Sue Mosher

"guiness_joe" <guinessjoe> wrote in message

news:AAC3AE07-59C1-4A01-9CD0-B825016F07FE@microsoft.com...
> Thank you Sue!

> 1) TI.Attachments.Add olItem, olEmbeddeditem, 1
> It attached an embedded picture of the email but not the email itself.

> 2) Your are right I have a personal folder which has Calendar and Task
> inside it, which I wish to use. The Folder name is 01 Handover/Calendars,
> and
> calendar folder name is Calendar and Task folder name is Task

> 5) If I create a couple of task form / templates, can I do all the
> previous
> mentioned steps, i.e. paste email and email body at the end of the task
> template body text? Also I want to have several Task forms / templates and
> want to use one that suits the task function.

> "Sue Mosher [MVP]" wrote:

> 1) the attached email is pasted at the end of the task body. I want it
> be pasted at the beginning of the task followed by the task body.
>
> > Since you're using Outlook 2003, you can handle this by using the third
> > parameter of the Attachments.Add method, which sets the position of the
> > attachment, e.g.:
>

>> TI.Attachments.Add olItem, olEmbeddeditem, 1
> >
> > >> 2) Do you mean that you want to create a task in a folder other than
> > >> your
> > >> default Tasks folder? Yes, the below task after being created saves
> > >> into
> > >> a Personal folder.

>

>> "a Personal Folder" doesn't really answer the question, but let's assume
> > you
> > wan to create a new item in a non-default folder. To do that, use the Add
> > method on the target folder's Items collection:
>

>> Set newItem = targetFolder.Items.Add("IPM.Task.YourFormName")
>

>> The message class parameter is optional.
>

>> To get a non-default folder, you need to walk the folder hierarchy using
> > the
> > Folders collections or use a function that does that for you. For an
> > example, see:
>

>> http://www.outlookcode.com/codedetail.aspx?id=628 - uses a folder
> > path
> > string
> >
> > > Can appointments be made of the Incomplete Task items that exist in the
> > > task
> > > folder?

>

>> Yes, using the same technique that you're already using to create a
> > task > > create the task then assign values to its properties.
>

>> "guiness_joe" <guinessjoe> wrote in message
> > news:81A9DE04-8FD9-4DE9-BEC1-B0DE643E338F@microsoft.com...
> >>> > "Sue Mosher [MVP]" wrote:
> >> >> 1) Outlook version? 2003
> > >
>> >> 2) Do you mean that you want to create a task in a folder other than
> > >> your
> > >> default Tasks folder? Yes, the below task after being created saves
> > >> into
> > >> a Personal folder.
> > >
>> >> 3) No.
> > >
>> >> 4) Please explain what you mean by that.
> > > Can appointments be made of the Incomplete Task items that exist in the
> > > task
> > > folder?
> > >
>> >> "guiness_joe" <guiness_joe> wrote in message
> > >> news:11BE8E23-486D-424E-922A-545A4BA15AFF@microsoft.com...
> > >> > Please find below code which converts email into a task, and pastes
> > >> > the
> > >> > email
> > >> > text body into the task body and also pastes the email as
> > >> > attachment.
> > >>> >> > Problem:
> > >>> >> > 1) the attached email is pasted at the end of the task body. I want
> > >> > it
> > >> > to
> > >> > be
> > >> > pasted at the beginning of the task followed by the task body.
> > >> > 2) Can the task be automatically be saved into a personal folder?
> > >> > 3) Is there a way to autotype the categories list by typing the
> > >> > first
> > >> > few
> > >> > letters?
> > >> > 4) Is there a way to auto fill calendar with the task items?
> > >>> >> > Public Sub AddCalendarEntry()
> > >> > Const mailItem_c As String = "MailItem"
> > >> > Dim OE As Outlook.Explorer ' olExp
> > >> > Dim MI As Outlook.MailItem
> > >> > Dim AI As Outlook.AppointmentItem
> > >> > Dim TI As Outlook.TaskItem ' olTask
> > >> > Dim olItem As Object
> > >>> >> > Set OE = Application.ActiveExplorer
> > >>> >> > 'Abort sub if no item selected:
> > >> > If OE.Selection.Count < 1 Then
> > >> > MsgBox "Please select an already saved message before" &
> > >> > vbCrLf
> > >> > & _
> > >> > "attempting to create an appointment or task" & vbCrLf & _
> > >> > "with this button ...", vbInformation, "No message selected
> > >> > ..."
> > >> > Exit Sub
> > >> > 'Abort sub if item selected is not a MailItem.
> > >> > ElseIf TypeName(OE.Selection(1)) <> mailItem_c Then
> > >> > MsgBox "You must select a mail item...", vbInformation,
> > >> > "Invalid
> > >> > selection..."
> > >> > Exit Sub
> > >> > End If
> > >>> >> > Set MI = OE.Selection(1)
> > >> > Beep
> > >> > Select Case MsgBox("Is calendar entry an appointment?" & vbLf & _
> > >> > "To Add Appointment (Yes) / To Add Task (No) / To Quit
> > >> > (Cancel)"
> > >> > &
> > >> > _
> > >> > vbCrLf, vbYesNoCancel + vbQuestion, "Create an appointment or
> > >> > task
> > >> > ...")
> > >> > Case vbYes 'If yes, create appointment
> > >> > Set AI = Outlook.CreateItem(olAppointmentItem)
> > >> > With AI
> > >> > .Subject = MI.Subject
> > >>> >> > .Body = MI.Body
> > >> > .Save
> > >> > .Display
> > >> > End With
> > >> > Case vbNo
> > >> > 'If no, create task due with date of today
> > >> > 'and due date is tomorrow at 10:00 am
> > >>> >> > Set TI = Application.CreateItem(olTaskItem)
> > >>> >> > With TI
> > >>> >> > Dim cntSelection As Integer
> > >> > cntSelection = OE.Selection.Count
> > >>> >> > For i = 1 To cntSelection
> > >>> >> > Set olItem = OE.Selection.Item(i)
> > >> > TI.Attachments.Add olItem
> > >>> >> > Next
> > >>> >> > .Subject = MI.Subject
> > >> > .Body = MI.Body
> > >> > ' .StartDate = Date
> > >> > ' .DueDate = Date + 1
> > >> > ' .ReminderTime = .DueDate & " 10:00"
> > >> > .Save
> > >> > .Display
> > >>> >> > End With
> > >>> >> > 'Case vbCancel
> > >> > ' Exit Sub
> > >> > End Select
> > >> > End Sub
 
An alternative to attaching an item to a task is try using a link instead.

Or prefix the item body with the other item's EntryID in the format shown at

http://www.slipstick.com/outlook/links.htm.

Sue Mosher

"Sue Mosher [MVP]" <suemvp@turtleflock.com> wrote in message

news:eTOjdcpGKHA.1492@TK2MSFTNGP03.phx.gbl...
> 1) This is a task you're attaching to? Tasks don't handle embedded items
> well, for reasons that have never been satisfactorily explained, IMO.

> 2) Then you need to follow the instructions I gave for using the Items.Add
> method. You will not, however, be able to use the GetFolder() function,
> because it assumes that there are no slashes in the folder name. Instead,
> you'll need to start at the top of the folder hierarchy and walk down,
> using the Folders collection of each MAPIFolder. If you need help with
> that, you will need to give us the complete and exact path to the
> folder(s), starting at the top of the hierarchy.

> 5) If you want to do all the same procedures in a custom form, then invoke
> the custom form using the message class parameter in the Items.Add method.

> > Sue Mosher
> > >

> "guiness_joe" <guinessjoe> wrote in message
> news:AAC3AE07-59C1-4A01-9CD0-B825016F07FE@microsoft.com...
> > Thank you Sue!
>

>> 1) TI.Attachments.Add olItem, olEmbeddeditem, 1
> > It attached an embedded picture of the email but not the email itself.
>

>> 2) Your are right I have a personal folder which has Calendar and Task
> > inside it, which I wish to use. The Folder name is 01 Handover/Calendars,
> > and
> > calendar folder name is Calendar and Task folder name is Task
>

>> 5) If I create a couple of task form / templates, can I do all the
> > previous
> > mentioned steps, i.e. paste email and email body at the end of the task
> > template body text? Also I want to have several Task forms / templates
> > and
> > want to use one that suits the task function.
>

>> "Sue Mosher [MVP]" wrote:
>

>> 1) the attached email is pasted at the end of the task body. I want it
> > be pasted at the beginning of the task followed by the task body.
> >
> >> Since you're using Outlook 2003, you can handle this by using the third
> >> parameter of the Attachments.Add method, which sets the position of the
> >> attachment, e.g.:
> >
>>> TI.Attachments.Add olItem, olEmbeddeditem, 1
> >
>>> >> 2) Do you mean that you want to create a task in a folder other than
> >> >> your
> >> >> default Tasks folder? Yes, the below task after being created saves
> >> >> into
> >> >> a Personal folder.
> >
>>> "a Personal Folder" doesn't really answer the question, but let's assume
> >> you
> >> wan to create a new item in a non-default folder. To do that, use the
> >> Add
> >> method on the target folder's Items collection:
> >
>>> Set newItem = targetFolder.Items.Add("IPM.Task.YourFormName")
> >
>>> The message class parameter is optional.
> >
>>> To get a non-default folder, you need to walk the folder hierarchy using
> >> the
> >> Folders collections or use a function that does that for you. For an
> >> example, see:
> >
>>> http://www.outlookcode.com/codedetail.aspx?id=628 - uses a folder
> >> path
> >> string
> >
>>> > Can appointments be made of the Incomplete Task items that exist in
> >> > the
> >> > task
> >> > folder?
> >
>>> Yes, using the same technique that you're already using to create a
> >> task > >> create the task then assign values to its properties.
> >
>>> "guiness_joe" <guinessjoe> wrote in message
> >> news:81A9DE04-8FD9-4DE9-BEC1-B0DE643E338F@microsoft.com...
> >>>>>> > "Sue Mosher [MVP]" wrote:
> >>>> >> 1) Outlook version? 2003
> >> >
>>> >> 2) Do you mean that you want to create a task in a folder other than
> >> >> your
> >> >> default Tasks folder? Yes, the below task after being created saves
> >> >> into
> >> >> a Personal folder.
> >> >
>>> >> 3) No.
> >> >
>>> >> 4) Please explain what you mean by that.
> >> > Can appointments be made of the Incomplete Task items that exist in
> >> > the
> >> > task
> >> > folder?
> >> >
>>> >> "guiness_joe" <guiness_joe> wrote in
> >> >> message
> >> >> news:11BE8E23-486D-424E-922A-545A4BA15AFF@microsoft.com...
> >> >> > Please find below code which converts email into a task, and pastes
> >> >> > the
> >> >> > email
> >> >> > text body into the task body and also pastes the email as
> >> >> > attachment.
> >> >>>> >> > Problem:
> >> >>>> >> > 1) the attached email is pasted at the end of the task body. I want
> >> >> > it
> >> >> > to
> >> >> > be
> >> >> > pasted at the beginning of the task followed by the task body.
> >> >> > 2) Can the task be automatically be saved into a personal folder?
> >> >> > 3) Is there a way to autotype the categories list by typing the
> >> >> > first
> >> >> > few
> >> >> > letters?
> >> >> > 4) Is there a way to auto fill calendar with the task items?
> >> >>>> >> > Public Sub AddCalendarEntry()
> >> >> > Const mailItem_c As String = "MailItem"
> >> >> > Dim OE As Outlook.Explorer ' olExp
> >> >> > Dim MI As Outlook.MailItem
> >> >> > Dim AI As Outlook.AppointmentItem
> >> >> > Dim TI As Outlook.TaskItem ' olTask
> >> >> > Dim olItem As Object
> >> >>>> >> > Set OE = Application.ActiveExplorer
> >> >>>> >> > 'Abort sub if no item selected:
> >> >> > If OE.Selection.Count < 1 Then
> >> >> > MsgBox "Please select an already saved message before" &
> >> >> > vbCrLf
> >> >> > & _
> >> >> > "attempting to create an appointment or task" & vbCrLf & _
> >> >> > "with this button ...", vbInformation, "No message selected
> >> >> > ..."
> >> >> > Exit Sub
> >> >> > 'Abort sub if item selected is not a MailItem.
> >> >> > ElseIf TypeName(OE.Selection(1)) <> mailItem_c Then
> >> >> > MsgBox "You must select a mail item...", vbInformation,
> >> >> > "Invalid
> >> >> > selection..."
> >> >> > Exit Sub
> >> >> > End If
> >> >>>> >> > Set MI = OE.Selection(1)
> >> >> > Beep
> >> >> > Select Case MsgBox("Is calendar entry an appointment?" & vbLf &
> >> >> > _
> >> >> > "To Add Appointment (Yes) / To Add Task (No) / To Quit
> >> >> > (Cancel)"
> >> >> > &
> >> >> > _
> >> >> > vbCrLf, vbYesNoCancel + vbQuestion, "Create an appointment
> >> >> > or
> >> >> > task
> >> >> > ...")
> >> >> > Case vbYes 'If yes, create appointment
> >> >> > Set AI = Outlook.CreateItem(olAppointmentItem)
> >> >> > With AI
> >> >> > .Subject = MI.Subject
> >> >>>> >> > .Body = MI.Body
> >> >> > .Save
> >> >> > .Display
> >> >> > End With
> >> >> > Case vbNo
> >> >> > 'If no, create task due with date of today
> >> >> > 'and due date is tomorrow at 10:00 am
> >> >>>> >> > Set TI = Application.CreateItem(olTaskItem)
> >> >>>> >> > With TI
> >> >>>> >> > Dim cntSelection As Integer
> >> >> > cntSelection = OE.Selection.Count
> >> >>>> >> > For i = 1 To cntSelection
> >> >>>> >> > Set olItem = OE.Selection.Item(i)
> >> >> > TI.Attachments.Add olItem
> >> >>>> >> > Next
> >> >>>> >> > .Subject = MI.Subject
> >> >> > .Body = MI.Body
> >> >> > ' .StartDate = Date
> >> >> > ' .DueDate = Date + 1
> >> >> > ' .ReminderTime = .DueDate & " 10:00"
> >> >> > .Save
> >> >> > .Display
> >> >>>> >> > End With
> >> >>>> >> > 'Case vbCancel
> >> >> > ' Exit Sub
> >> >> > End Select
> >> >> > End Sub


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P How do I convert outlook “to-do” items to “tasks” Outlook VBA and Custom Forms 1
B Outlook tasks and PDF Using Outlook 4
petunia Outlook tasks module sunsetting? Exchange Server Administration 3
Fozzie Bear Shared Calendar For Scheduled Tasks Using Outlook.com accounts in Outlook 3
R unable to filter tasks when start date is on or before today Using Outlook 3
S Sync Outlook (2021) tasks with Microsoft To Do Using Outlook 1
S Appointment font size when printing only changes Tasks' font Using Outlook 0
L Format Lost between Tasks and To Do Using Outlook 0
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
V Backup Calendar, Contacts, Tasks in an POP3 data file Using Outlook 3
V Outlook 2016 iCloud for Windows - Why no working Calendars and Tasks ? Using Outlook 1
T Outlook 365 Move newly created tasks automatically on save. Outlook VBA and Custom Forms 1
Z Import Tasks from Access Using VBA including User Defined Fields Outlook VBA and Custom Forms 0
P Outlook tasks keeps changing (updating) dates that I type Using Outlook 2
kburrows Reset Date to Keep Tasks from Archiving Using Outlook 9
O Moving "tasks" to inbox in Outlook 2016 Using Outlook 1
O Tasks - how to display "snoozed" tasks and snooze-times? Using Outlook 7
T Outlook 2010 Tasks are not visible in To Do list Using Outlook 5
T Outlook creating unwanted tasks in Tasks and Todo from emails Using Outlook 1
S Copy Tasks/Reminders from Shared Mailbox to Personal Tasks/Reminders Outlook VBA and Custom Forms 0
S Outlook 2016 Arrange tasks by date, additional custom sorting, but still use friendly terms like Today, Tomorrow, This week? Using Outlook 1
V Outlook 2016 Multiple recurring tasks getting created Using Outlook 0
peterbata Shared Tasks Outlook for Mac Using Outlook 5
K Outlook tasks formatting Using Outlook 4
G Move tasks up/down todo list by VBA Outlook VBA and Custom Forms 1
L Unable to Sync Web/Android MS To Do with Windows Outlook Tasks Using Outlook 3
O Outlook tasks - Add text column with multiple lines Using Outlook 3
U Macro for reminders,tasks,calendar Outlook VBA and Custom Forms 4
G Recurring tasks break links Outlook 2016 Using Outlook 5
Y Outlook 2013 Stop Outlook from automatically assigning categories to Tasks Using Outlook 0
P Outlook tasks not syncing with iCloud Using Outlook 2
P Searching tasks that are archived Using Outlook 4
B All imported tasks appear in to-do list Using Outlook 3
T Extract Data From Outlook Tasks Using Outlook 0
T Extract Data From Outlook Tasks Using Outlook 0
I To-do bar (tasks) Using Outlook 1
O Tasks - Is there a postponed date column? Using Outlook 7
O Outlook 365 - Tasks are not synchronizing? Using Outlook 7
F some tasks are disappearing Using Outlook 4
F How to show assigned tasks under certain mailbox? Using Outlook 4
B iCloud Option to sync contacts, mail, calendar and tasks Using Outlook 5
M tasks in todo list appearing twice Using Outlook 3
J what file contains contacts, tasks and appointments stored locally? Using Outlook 1
F Finding Meetings/Tasks in a date range Using Outlook 1
F Sharepoint tasks from multiple accounts in To-Do List Using Outlook 8
F Search folder for tasks in all task folders Using Outlook 1
B Creating an email with the list of tasks Outlook VBA and Custom Forms 0
J Outlook 2016 - Tasks View Settings Missing Using Outlook 1
copperberry How to view all tasks across task folders Using Outlook 3

Similar threads

Back
Top