![]() |
#1
|
|||
|
|||
![]()
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 |
#2
|
||||
|
||||
![]()
I haven't tested your code, but if it works then
Code:
.Subject = objOriginalItem.Subject
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
Unfortynately, it didn't work.
Maybe I need some Dim code snippets? |
#4
|
||||
|
||||
![]()
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
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
![]()
Thank you, it worked.
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
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 |