Solved

Outlook macro

Posted on 2014-04-24
7
600 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
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
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.
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

920 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

16 Experts available now in Live!

Get 1:1 Help Now