Solved

Outlook macro

Posted on 2014-04-24
7
593 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
  • 4
  • 3
7 Comments
 

Author Comment

by:easycapital
Comment Utility
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
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 76

Expert Comment

by:David Lee
Comment Utility
You're welcome!
0
 

Author Comment

by:easycapital
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Learn more about how the humble email signature can be used as more than just an electronic business card. When used correctly, a signature can easily be tailored for different purposes by different departments within an organization.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now