Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-03-2016, 07:36 AM
perola.rike perola.rike is offline VBA forward to gmail - include original subject Windows 7 32bit VBA forward to gmail - include original subject Office 2007
Novice
VBA forward to gmail - include original subject
 
Join Date: Feb 2016
Posts: 5
perola.rike is on a distinguished road
Default VBA forward to gmail - include original subject

I have this code that perfectly forwards all my outlook mails to gmail. Only one thing is missing: In gmail, there is "no subject". Can anyone help me modify the code below to include the original subject in the forwarded mail?

In "this outlook session":

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim varEntryID As Variant
Dim objOriginalItem As MailItem
Dim newMail As MailItem

For Each varEntryID In Split(EntryIDCollection, ",")
Set objOriginalItem = Application.GetNamespace("MAPI").GetItemFromID(var EntryID)

Do Until objOriginalItem.Attachments.Count = 0
objOriginalItem.Attachments.Remove (1)
Loop

Set newMail = CreateItem(olMailItem)

With newMail

.To = "MYMAILHERE@gmail.com"
.Subject
.Attachments.Add objOriginalItem
.Display

.Send


End With


Next

ExitRoutine:
Set objOriginalItem = Nothing
Set newMail = Nothing

End Sub
Reply With Quote
  #2  
Old 02-03-2016, 09:55 PM
gmayor's Avatar
gmayor gmayor is offline VBA forward to gmail - include original subject Windows 10 VBA forward to gmail - include original subject Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I haven't tested your code, but if it works then
Code:
.Subject = objOriginalItem.Subject
would seem to fit the bill.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 02-04-2016, 04:24 AM
perola.rike perola.rike is offline VBA forward to gmail - include original subject Windows 7 32bit VBA forward to gmail - include original subject Office 2007
Novice
VBA forward to gmail - include original subject
 
Join Date: Feb 2016
Posts: 5
perola.rike is on a distinguished road
Default

Unfortynately, it didn't work.
Maybe I need some Dim code snippets?
Reply With Quote
  #4  
Old 02-04-2016, 06:54 AM
gmayor's Avatar
gmayor gmayor is offline VBA forward to gmail - include original subject Windows 10 VBA forward to gmail - include original subject Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I would do things differently. As I understand it from your code, you want to send a copy of each message you send to another e-mail address but with any attachments removed? That being the case
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim olCopy As MailItem
Dim olAtt As Attachment
    Set olCopy = Item.Forward
    With olCopy
        For Each olAtt In olCopy.Attachments
            olAtt.Delete
        Next olAtt
        .To = "someone@gmail.com"
        .Send
    End With
lbl_Exit:
    Exit Sub
End Sub
should work.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 02-04-2016, 11:43 PM
perola.rike perola.rike is offline VBA forward to gmail - include original subject Windows 7 32bit VBA forward to gmail - include original subject Office 2007
Novice
VBA forward to gmail - include original subject
 
Join Date: Feb 2016
Posts: 5
perola.rike is on a distinguished road
Default

Thank you, it worked.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA forward to gmail - include original subject Auto-forward HTML emails with added suffix to subject line paulkaye Outlook 18 01-24-2016 11:42 PM
VBA rule to forward messages from specific folder and forward Bursal Outlook 16 09-23-2015 04:09 AM
Change subject to include date and time in subject officechris Outlook 1 05-01-2015 09:58 PM
Need to forward subject alone of mails abhikulsh Outlook 1 08-28-2013 10:47 AM
Using a rule: How do I include a copy of the original e-mail message when sending an Emerogork Outlook 0 04-09-2012 07:11 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:38 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft