Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite

Status
Not open for further replies.

JaCrispy

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Hello,

So I have VBA code to reply to a normal email with attachment, but I need help to modify the code below so that it can also work when you reply from a meeting invitation using email to include the attachments that are included in that meeting invite. If you use the "forward" option from a meeting invite, it forwards the actual meeting invitation, which is not what I would like to do. I would like to reply to the meeting invite and include the attachments.

Code:
Sub ReplyWithAttachments()
    Dim rpl As Outlook.MailItem
    Dim itm As Object
    
    Set itm = GetCurrentItem()
    If Not itm Is Nothing Then
        Set rpl = itm.Reply
        CopyAttachments itm, rpl
        rpl.Display
    End If
    
    Set rpl = Nothing
    Set itm = Nothing
End Sub

Function GetCurrentItem() As Object
    Dim objApp As Outlook.Application
        
    Set objApp = Application
    On Error Resume Next
    Select Case TypeName(objApp.ActiveWindow)
        Case "Explorer"
            Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
        Case "Inspector"
            Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
    End Select
    
    Set objApp = Nothing
End Function

Sub CopyAttachments(objSourceItem, objTargetItem)
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
   strPath = fldTemp.Path & "\"
   For Each objAtt In objSourceItem.Attachments
      strFile = strPath & objAtt.FileName
      objAtt.SaveAsFile strFile
      objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
      fso.DeleteFile strFile
   Next

   Set fldTemp = Nothing
   Set fso = Nothing
End Sub
Thanks!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Because you don't reply to meetings, Set rpl = itm.Reply won't work. I think you'll need to create a new message - there is a send mail to attendees command but i don't know if it is exposed in the object model. (will look later)

Code:
Set replyMeeting = Application.CreateItem(olMailItem)
  replyMeeting.Body = item.body
  replyMeeting.Subject = "Re: " & item.subject
  replyMeeting.To = item.organizer ' not sure if this is right
  replyMeeting.Display ' use .send to send
if you want to reply to all attendees, see Send an email to attendees who have not responded (it can be tweaked to reply to all)
 

JaCrispy

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Hello,

Thanks for your tip. I have tried implementing it, but it's not working so far :\
 

JaCrispy

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Hello,

Thanks for your tip. I have tried implementing it, but it's not working so far :\
Actually.. I did get it working, but the format of the body of the invitation gets stripped out and any pictures etc are missing. any ideas?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Baby steps...

This works (you need the functions from your macro) - but you need to select all and copy the appt body to the clipboard before running the macro. :(

Code:
Sub ConvertSelectionToAppointment()
' You need the GetCurrentItem Function from
'http://slipstick.me/e8mio

    Dim objMail   As Outlook.AppointmentItem
    Dim objAppt As Outlook.MailItem
  
    ' Add reference to Word library
    ' in VBA Editor, Tools, References
    Dim objInsp As Inspector
    Dim objDoc As Word.Document
    Dim objSel As Word.Selection

    Set objMail = GetCurrentItem()
      
    On Error Resume Next
 
  If Not objMail Is Nothing Then
            Set objInsp = objMail.GetInspector
                Set objDoc = objInsp.WordEditor
                Set objWord = objDoc.Application
                Set objSel = objWord.Selection
        With objSel
           'use wholestory to copy the entire message body
 ''            .WholeStory
  '           .Copy
       End With
 
    End If
    

Set replyMeeting = Application.CreateItem(olMailItem)
    Set objInsp = replyMeeting.GetInspector
    Set objDoc = objInsp.WordEditor
    Set objSel = objDoc.Windows(1).Selection


CopyAttachments objMail, replyMeeting
    objSel.PasteAndFormat (wdFormatOriginalFormatting)

    objSel.Range.InsertParagraphBefore
    objSel.Range.InsertParagraphBefore
 
  replyMeeting.Subject = "Re: " & objMail.Subject
  replyMeeting.To = objMail.Organizer ' not sure if this is right
  replyMeeting.Display ' use .send to send
    
    objMail.Categories = "Appt" & objMail.Categories
    Set objAppt = Nothing
    Set objMail = Nothing
End Sub
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
Marc2019 Need help please! Cannot Setup my outlook email account on my Mac Outlook 2011 Using Outlook.com accounts in Outlook 2
L Outlook 2002: HTML Emails Will Not Print: Please Help Using Outlook 0
joflo copy contents from outlook to excell - please help. Using Outlook 4
C Please Help outlook 2013 Using Outlook 1
F Help with Outlook 2007 Macro Please! Using Outlook 4
A outlook error Receiving reported error (0x80040900) please help Using Outlook 4
D Help please my Outlook is frozen Using Outlook 3
H Outlook 2010: Cannot start!, please help me! Using Outlook 3
D Outlook 2007 not working>> Please help tried everything Using Outlook 3
U Need a help please Outlook 2007 crashing Using Outlook 2
B Please help! Outlook, Exchange Server, and Customization BCM (Business Contact Manager) 2
B Please help! Outlook, Exchange Server, and Customization Exchange Server Administration 0
S Outlook Performance Issues - Help please! Using Outlook 1
W I have outlook 2007, and it is not saving my contacts when I send an email, please help! Using Outlook 2
X Outlook Not Showing All Contacts, but they are listed in Exchange - Please Help Exchange Server Administration 5
H Restore emails to Microsoft Outlook Web Access that were drawn down by Outlook 2003 - Help PLEASE! Exchange Server Administration 4
J Re: Please help correct Error on step 4 of converting Windows mail to Office Outlook 2007(already installed). Using Outlook 3
T Outlook 2010 wwlib.dll error when opening certain emails, open fine with plain text, please help! Using Outlook 4
R Please Help: How to format muti-line address in Excel file before importing to Outlook 2010 Using Outlook 1
G URGENT!! Outlook 2003 inbox problem please help Using Outlook 1
J I can't open any links from my Microsoft Outlook 2007 e-mails. Please help me. Using Outlook 3
C outlook hotmail connector update killed my outlook - please help!! Using Outlook.com accounts in Outlook 3
J Outlook 2003 with Outlook Connector - added new account, unable to view any items in inbox, nor send from that account. Help please! Using Outlook 7
D I am unable to setup my Outlook using my Yahoo.com mail account. HELP PLEASE!!!! Using Outlook 2
D Outlook 2010 Pro Plus- All mail moved by a Rule is copied to trash folder, please help Using Outlook 4
J Cannot synch hotmail with Outlook 2003 even using outlook connector - please help! Using Outlook 1
V I am having a hard time setting up my yahoo mail in Outlook. Please help! Using Outlook 2
I Outlook 2007 instant search yielding no result even after extensive troubleshooting. please help! Using Outlook 2
D Contacts are being automatically deleted from Microsoft Outlook. Please Help! Using Outlook 2
G Help with Microsoft Outlook folders please Using Outlook 2
K Outlook is open all the time - please help Using Outlook 1
M outlook 2007 very slow to insert UNC hyperlink on windows 7 professional ... please help Using Outlook 7
J Outlook 2007 keeps prompting for password after update, please help! Using Outlook 11
J My outlook hang in last email Help please! Using Outlook 5
R i want notifier in outlook express , please help how can i get ? Outlook VBA and Custom Forms 1
C Outlook 2007 Wacky Issue - Please Help Outlook Wishlist 1
V Outlook macro help please Outlook VBA and Custom Forms 23
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
A Help with VBA please! Outlook VBA and Custom Forms 15
Denis Hi everyone!!! Need some help with Excel to Exchange Calendar??PLEASE>>> Using Outlook 1
V Please help if you can. Problems with Bcc BCM (Business Contact Manager) 3
J Please help to clarify an IMAP issue Using Outlook 7
M Address book doesn't update contacts? Please any help would be great! Exchange Server Administration 4
N Please help....winmail.dat issue...slowly going insane..... Using Outlook 1
A help please -Boolean - can I use .AND NOT etc in a rule Exchange Server Administration 0
A Advanced find query facilty Help please Using Outlook 2
C Can't import distribution list - help, please Using Outlook 1
V [duplicates duplicates duplicates] please help Using Outlook 26
I can't view email body please help! Using Outlook 6
Similar threads


















































Top