VBA: How do I add a shortcut to an email into the body of an appointment

Dear all,
I want to write a macro for outlook that lets me do the following:
1. Move a selected email to a specific folder (with selection box)
2. create an appointment in a non default calendar with the same subject as the email
3. Put a link into the appointment body that links to the email (similar to the option that Outlook gives you when you drag an email onto the calender: "Copy Here as Appointment with Shortcut")
Unfortunately step 3 (creating the link to the email) can not be recreated unsing QuickSteps. Therefore I have to solve this with VBA.
Here is the code I came up with so far:
Sub Mail2Appt()
' Moves each of the selected items on the screen to a selected folder.
Dim olApp As New Outlook.Application
Dim olExp As Outlook.Explorer
Dim olSel As Outlook.Selection
Dim olNameSpace As Outlook.NameSpace
Dim olDestFolder As Outlook.Folder
Dim intItem As Integer
Set olExp = olApp.ActiveExplorer
Set olSel = olExp.Selection
Set olNameSpace = olApp.GetNamespace("MAPI")
'1. Handle the movement of the selected emails
'Display form to pick destination Folder
Set olDestFolder = olNameSpace.PickFolder
'To do: folder type validation
If TypeName(olDestFolder) <> "Nothing" Then
'Debug.Print vbCr & " olDestFolder: " & olDestFolder
Else
'Debug.Print vbCr & "Cancel"
Exit Sub
End If
'Move selection to new folder
For intItem = 1 To olSel.Count
olSel.Item(intItem).Move olDestFolder
Next intItem
'2. Create appointment in To-Do-Calendar
Dim myCalItem As Outlook.AppointmentItem
Dim myToDoCalendar As Outlook.Folder
'get non-default calender
Set myToDoCalendar = Session.GetDefaultFolder(olFolderCalendar).Parent.Folders("Aufgaben-Kalender")
For intItem = 1 To olSel.Count
Set myCalItem = myToDoCalendar.Items.Add(olAppointmentItem)
myCalItem.Subject = olSel.Item(intItem).Subject
myCalItem.Location = "Office"
myCalItem.Duration = 30
'3. Place link to email in appointment body
myCalItem.Body = "Hello World" 'Link to Email must go here
myCalItem.Display
Next intItem
End Sub
It would be great if somebody could push me in the right direction.
Cheers,
Sascha

To Edit the body you need to invoke the WordEditor Inspector. You can then program the body as if you were programming in Word itself e.g.
Add these declarations
Dim olInsp As Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim strLink As String
Then substitute your own link
With myCalItem
.Subject = olSel.Item(intItem).Subject
.Location = "Office"
.Duration = 30
'3. Place link to email in appointment body
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range(0, 0)
.Display
oRng.Text = "Hello World " 'Link to Email must go here
oRng.collapse 0
strLink = "https://www.fedex.com/fedextrack/?tracknumbers="
wdDoc.Hyperlinks.Add Anchor:=oRng, _
Address:=strLink, _
SubAddress:="", _
ScreenTip:="", _
TextToDisplay:="Fedex Tracking Site"
End With
Graham Mayor - Word MVP
www.gmayor.com

Similar Messages

  • How can I add an icon for an application into the dock?

    I just installed an application that I will using often, but I cannot add it to the dock for some reason. I tried dragging it from the applications menu but that didn't work. How can I get it on the dock? Thanks in advance

    Launch the application and then press the Control key or hold down the mouse/trackpad button while clicking on its icon in the Dock; choose Keep In Dock from the menu which appears.
    (20007)

  • How do I insert a flyer made in Photoshop into the body of an email...

    I made a flyer in Photoshop, I saved it as a JPG. Then I went into my email client AOL to insert it into the body of the email to send out to my clientele. I sent it to myself first to check the resolution etc. The problem is I cannot get it to keep the orginal aspect ration within the email. I compared it to other flyers sent to me, that were produced in Photoshop, I checked all the specs and everything in them matched mine. When I put them into the email the retained their orginal format. So what am I doing wrong that mine will not. I am sure it is something simple I am not aware of doing as I am new to the program.
    Any assistance would be greatly appreciated. I am working in Photoshop CS3 on a Dell.
    BJ

    What happens if your recipients' email clients do not display images by default? Will your message still get across?
    http://www.emaillabs.com/tools/email-marketing-statistics.html#blockedimages
    Hopefully, you have no more than 100 recipients to your email marketing as AOL imposes a limit.
    The comparison between messages you send and those you have received should be clearly made. Were those messages that you received sent from AOL? Were they sent with the same AOL mail client? Do they use images attached to the message or called from a web server?

  • How do i insert my pdf (with clickable links) into the body of an email?

    I do not want to use mail chimp, copy & paste, or take a screenshot.  Since I have updated my programs I am no longer able to do this and that seems pretty backwards to me.

    What happens if your recipients' email clients do not display images by default? Will your message still get across?
    http://www.emaillabs.com/tools/email-marketing-statistics.html#blockedimages
    Hopefully, you have no more than 100 recipients to your email marketing as AOL imposes a limit.
    The comparison between messages you send and those you have received should be clearly made. Were those messages that you received sent from AOL? Were they sent with the same AOL mail client? Do they use images attached to the message or called from a web server?

  • How do I add a shortcut to the home page of my iMac

    How do I add a shortcut icon to my homepage on my IMac ...... Not a bookmark but a shortcut

    No offense intended ..... I just give up ... That's all ...... Learning Apple specifics sometimes (most times) not worth the effort .....  Also .... I never spoke to your intelligence ...... and said thanks for your time ..... So again .... Thanks anyway ..... It's not that important to me to solve this insignificant riddle ..... I am glad this forum is here though ..

  • How can I add/change art work to albums where the art work isn't available at iTunes?

    How can I add/change art work to albums where the art work isn't available at iTunes?

    Go to google and search for the artwork.  When you find it, save it to your computer.  Right click the album and select get info.  Drag the image you saved to the empty box for album art.

  • How do I add multiple pages from my scanner to the adobe app?

    How do I add multiple pages from my scanner to the adobe app?

    You can't do this in Reader. It must be done in Acrobat on Windows or Macintosh.

  • How do I add page numbers to my document without the page numbers automatically changing. I do not want the page numbers the software automatically places into my document.

    How do I add page numbers to my document without the page numbers automatically changing? The title page is blank, I can type in 1 on the 1st typed page, but the #1 automatically goes into the next page and will not change.

    Click at bottom of the first page:
    Menu > Insert > Section break
    Click somewhere in the 2nd page (not the header/footer)
    Inspector > Layout > Section > Page Numbers > Start at 1 > Configuration > uncheck use previous headers and footers
    Click into the header or footer of the second page:
    Menu > Insert > Auto Page Numbers…
    If there is anything in the header or footer on the first page that you don't want just select it and delete it.
    If you really wanted to manual place page numbers on each page you will have to use a section break between each and every page. I can't imagine that would be useful.
    Peter

  • How do I add a recurring event to repeat on the fifth recurring day of the month, for example, an event that only happen on the fifth Sunday of the month for those months that have a fifth Sunday?

    How do I add a recurring event to repeat on the fifth recurring day of the month, for example, an event that only happen on the fifth Sunday of the month for those months that have a fifth Sunday?

    Create one on the first Tuesday, select repeat/monthly and take the option at the bottom.

  • How do I add a "written" signature to emails?

    how do I add a "written" signature to emails?

    Mail->Preferences->Signatures, press [+], then drag the image of your signature

  • How can i import tables from a different schema into the existing relational model... to add these tables in the existing model? plss help

    how can i import tables from a different schema into the existing relational model... to add these tables in the existing relational/logical model? plss help
    note; I already have the relational/logical model ready from one schema... and I need to add few more tables to this relational/logical model
    can I import the same way as I did previously??
    but even if I do the same how can I add it in the model?? as the logical model has already been engineered..
    please help ...
    thanks

    Hi,
    Before you start, you should probably take a backup copy of your design (the .dmd file and associated folder), in case the update does not work out as you had hoped.
    You need to use Import > Data Dictionary again, to start the Data Dictionary Import Wizard.
    In step 1 use a suitable database connection that can access the relevant table definitions.
    In step 2 select the schema (or schemas) to import.  The "Import to" field in the lower left part of the main panel allows you to select which existing Relational Model to import into (or to specify that a new Relational Model is to be created).
    In step 3 select the tables to import.  (Note that if there are an Foreign Key constraints between the new tables and any tables you had previously imported, you should also include the previous tables, otherwise the Foreign Key constraints will not be imported.)
    After the import itself has completed, the "Compare Models" dialog is displayed.  This shows the differences between the model being imported and the previous state of the model, and allows you to select which changes are to be applied.
    Just selecting the Merge button should apply all the additions and changes in the new import.
    Having updated your Relational Model, you can then update your Logical Model.  To do this you repeat the "Engineer to Logical Model".  This displays the "Engineer to Logical Model" dialog, which shows the changes which will be applied to the Logical Model, and allows you to select which changes are to be applied.
    Just selecting the Engineer button should apply all the additions and changes.
    I hope this helps you achieve what you want.
    David

  • IF_IXML : How can i add encoding with value UTF-8 to the document object??

    Hi
    i want to create a xml file with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <OpenSearchDescription xmlns="http://...."> 
    </OpenSearchDescription>
    i did this with the if_ixml interface and rendered the content in a file 'D:\usr\sap\IFD\DVEBMGS01\log\TEST_out.xml
    <?xml version="1.0"?>
    <OpenSearchDescription xmlns="http://...."> 
    </OpenSearchDescription>
    BUT the document attribut(?) encoding="UTF-8"?> is missing!
    How can i add encoding with value UTF-8 to the document object?? it should look like:
    <?xml version="1.0" encoding="UTF-8"?>
    *here is my coding.
    TYPE-POOLS: ixml.
    CLASS cl_ixml DEFINITION LOAD.
    DATA: lo_ixml           TYPE REF TO if_ixml,
          lo_streamfactory  TYPE REF TO if_ixml_stream_factory,
          lo_document       TYPE REF TO if_ixml_document,
          lo_parent         TYPE REF TO if_ixml_element,
          lo_ostream        TYPE REF TO if_ixml_ostream,
          lo_renderer       TYPE REF TO if_ixml_renderer,
         lv_rc           TYPE i.
    lo_ixml = cl_ixml=>create( ).
    lo_streamfactory = lo_ixml->create_stream_factory( ).
    lo_document = lo_ixml->create_document( ).
    lo_parent = lo_document->create_simple_element( name   = 'OpenSearchDescription'  "root node
                                                    parent = lo_document ).
    lo_parent->set_attribute_ns( name   =  'xmlns'
                                 value  = 'http://....' ).
    *rausrendern in file
    lo_ostream = lo_streamfactory->create_ostream_uri( system_id = 'D:\usr\sap\IFD\DVEBMGS01\log\TEST_out.xml' ).
    lo_renderer = lo_ixml->create_renderer( ostream  = lo_ostream
                                            document = lo_document ).
    lv_rc = lo_renderer->render( ).
    Thanks for help
    Britta

    Use the following code:
    set an document encoding
      l_encoding = l_ixml->create_encoding( character_set = 'UTF-8'
                                            byte_order = if_ixml_encoding=>co_none ).
      l_success  = l_ostream->set_encoding( encoding = l_encoding ).
    create a xml renderer
      l_renderer = l_ixml->create_renderer( document = l_doc ostream  = l_ostream ).

  • How do i add a photo to an email as an attachment and not an image?

    How do I add a photo to an email as an attachment? Everytime I try to and the attachment it puts the photo in the email as an image not a file attachment.

    Control+Click or right click on the image in the email and select 'view as icon'. Also make sure you have 'Send Windows-friendly attachments' selected in Mail>Edit>Attachments.

  • How do I add a star to an email in my inbox

    How do I add a star to an email in my inbox

    Did you try clicking in the Star column for that message?
    How about right click and select Mark-Add Star?
    Maybe Message-Mark-Add Star?

  • How does one add a personal recorded M4R file to the ring tones in the UK system for iPhone 3GS

    How does one add a personal recorded M4R file to the ring tones in the UK system for iPhone 3GS.
    I have tried all sorts of ways of adding my personal M4R file but can't find the place (within the UK versions of iTunes} to transfer this file so that I can select it as a ring tone.
    I've tried also changing to the US version of iTunes and still can't find a way of doing it, although I have heard that it can be done.

    You should be able to just drop it into the library within iTunes.
    http://cnettv.cnet.com/create-free-iphone-ringtones-using-itunes-8-0/9742-1_53-5 0003920.html
    Check out the video above for a lot good info. The ringtone must be less than 35 seconds.

Maybe you are looking for