Solved

Outlook macro

Posted on 2014-04-24
7
606 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell to list unused Group Policy Object ? 9 88
outlook 365 3 62
Excel VBA - Import Mail Headers in Excel from Specific Folder 3 40
MS Exchange 2016 license 5 34
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
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…

738 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