+ Reply to Thread
Results 1 to 3 of 3

VBA forward to gmail - how to include original subject in forwarded mail?

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    10

    VBA forward to gmail - how to include original subject in forwarded mail?

    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 = "[email protected]"
    .Subject
    .Attachments.Add objOriginalItem
    .Display

    .Send
    End With


    Next

    ExitRoutine:
    Set objOriginalItem = Nothing
    Set newMail = Nothing

    End Sub

  2. #2
    Forum Contributor
    Join Date
    08-27-2006
    Posts
    136

    Re: VBA forward to gmail - how to include original subject in forwarded mail?

    Instead of .Subject
    Please Login or Register  to view this content.
    To mark "Solved" go to Thread Tools.

  3. #3
    Registered User
    Join Date
    07-03-2013
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: VBA forward to gmail - how to include original subject in forwarded mail?

    Thank you, I got your line incorporated in a new code that forwards all my outlook mails as desired, including the original subject:

    Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    Dim varEntryID As Variant
    Dim objForwardedItem As MailItem
    Dim objOriginalItem As MailItem
    Dim newMail As MailItem
    On Error Resume Next
    For Each varEntryID In Split(EntryIDCollection, ",")
    'denne under lagt til
    Set objOriginalItem = Application.GetNamespace("MAPI").GetItemFromID(varEntryID) 'det er denne som henter originalsender adresse....ser det ut til...
    Set newMail = CreateItem(olMailItem)
    With newMail
    .To = "[email protected]"
    .Attachments.Add objOriginalItem
    .Subject = objOriginalItem.Subject
    .Display
    .Send
    End With

    Next

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Forward Email Based on Selected Object's Subject and/or Sender and Recipient Address
    By Citanaf in forum Outlook Programming / VBA / Macros
    Replies: 2
    Last Post: 12-11-2015, 07:38 PM
  2. My default mail program must open with [email protected] when I click A1 cell...
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-28-2015, 10:05 AM
  3. How to include excel cells on the email body using gmail
    By ivhee00 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2015, 10:38 AM
  4. Sendig mail from Gmail account
    By Hamzaoui in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-05-2015, 08:49 AM
  5. Sending mail with range as body using GMAIL
    By vssoma in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2014, 05:40 AM
  6. email with corresponding addresses and names in body AND subject using gmail
    By excel4phil in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-22-2013, 04:09 AM
  7. Trying to save mail attachments with the mail subject as the filename
    By thereth in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-09-2010, 05:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1