Solved

Outlook macro

Posted on 2014-04-24
7
608 Views
Last Modified: 2014-07-01
Dear Expert,

Needing help with a macro in Outlook 2010 to accomplish the following when I have highlighted a email from the email list:

1. Create a task with both email content (maintain original format) and add email attachment at beginning of task.
1.1 Include in the first part of above step the general info missing within the body of the email:
   a. The date sent details.
   b. The sender info
   c. To:, CC: info
   d. the subject.
2. Set Tast Start Date to "today"
3. Set priority to "Low"
4. Leave Task open for me to continue editing as needed.

In following expert request I will request to convert this task into its original email. Perhaps use the attached email attachment?

Best regards,
JP
0
Comment
Question by:easycapital
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 

Author Comment

by:easycapital
ID: 40020220
Also please add in first step #1 above (in general the info missing within the body of the email):
a. The date sent details.
b. The sender info
c. To:, CC: info
d. the subject.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 40020534
Hi, easycapital.  

This should do it.  I'm assuming that you know how to add macro code to Outlook.  If you don't, then let me know and I'll post instructions on how to do that.

Sub MakeTask()
    Const MACRO_NAME = "Make Task"
    Const wdPasteDefault = 0
    Const wdStory = 6
    Dim olkMsg As Object, olkD1 As Object, olkD2 As Object, olkTsk As Object, strInf As String
    Select Case TypeName(Application.ActiveWindow)
        Case "Explorer"
            Set olkMsg = Application.ActiveExplorer.Selection(1)
        Case "Inspector"
            Set olkMsg = Application.ActiveInspector.CurrentItem
    End Select
    If olkMsg.Class = olMail Then
        strInf = vbCrLf & "Received: " & olkMsg.ReceivedTime & vbCrLf
        strInf = strInf & "From: " & olkMsg.SenderName & vbCrLf
        strInf = strInf & "To: " & olkMsg.To & vbCrLf
        If olkMsg.CC <> "" Then
            strInf = strInf & "CC: " & olkMsg.CC & vbCrLf
        End If
        strInf = strInf & "Subject: " & olkMsg.Subject
        Set olkD1 = olkMsg.GetInspector.WordEditor
        olkD1.Parent.Selection.WholeStory
        olkD1.Parent.Selection.Copy
        Set olkTsk = Application.CreateItem(olTaskItem)
        olkTsk.Display
        With olkTsk
            .Body = strInf & vbCrLf & vbCrLf
            Set olkD2 = .GetInspector.WordEditor
            olkD2.Parent.Selection.EndKey wdStory
            olkD2.Parent.Selection.PasteAndFormat (wdPasteDefault)
            .Attachments.Add olkMsg, , 1
            .StartDate = Date
            .Importance = olImportanceLow
        End With
    Else
        MsgBox "Operation cancelled.  you must select an email for this macro to work.", vbCritical + vbOKOnly, MACRO_NAME
    End If
    Set olkMsg = Nothing
    Set olkD1 = Nothing
    Set olkD2 = Nothing
    Set olkTsk = Nothing
End Sub

Open in new window

0
 

Author Closing Comment

by:easycapital
ID: 40021780
Many thanks for the help.
I will open another question to address the creation of more than one macro in Outlook.
I am at basic level with Macros in Outlook.
Br,
JP
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 76

Expert Comment

by:David Lee
ID: 40022238
You're welcome!
0
 

Author Comment

by:easycapital
ID: 40153301
Dear BlueDevilFan.
Do you get messages for answered questions by any chance?

I just noticed that the above macro creates a Task only shows up under To-Do-List and I would like to have it show up under Tasks section. What should I do?
Note: I have two email accounts. I want it under the email account I receive it under,
Otherwise, could we just hard code the specific task folder where I want them to appear in?
Should I create a new question?
Br,
JP
0
 
LVL 76

Expert Comment

by:David Lee
ID: 40170438
Hi, JP.

I do.  

I'm not sure I understand.  The code creates the task in the default task folder.  Are you saying that you want the code to look at which account the source email came in through and create the task in the task folder associated with that account?
0
 

Author Comment

by:easycapital
ID: 40170624
You will notice that in the Task window there is a first section for "to do lists" - these are "mail tasks". Meaning that if you delete that type of task later, then you also erase the email. But if the task is instead created in "task" section of this window, then there is no relationship to the original plus certain time management phone apps just pick up "tasks" and not "to do list".
I opened a question under
http://mobile.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_28463865.html
Thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question