Results 1 to 10 of 18

Thread: Excel VBA to Attach File And Automatically Send Email

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    9
    Rep Power
    0

    Forward mails with attachment in excel VBA code

    Quote Originally Posted by Friel300 View Post
    E-Mailing from excel

    hey this is a piece from my refereence file
    it should work pretty well.

    it should all be pretty straight forward to taylor to your needs.

    Code:
    Sub Mail_small_Text_Outlook()
    'Working in Office 2000-2010
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strbody As String
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
        strbody = "Hi there" & vbNewLine & vbNewLine & _
                  "Cell A1 is changed" & vbNewLine & _
                  "This is line 2" & vbNewLine & _
                  "This is line 3" & vbNewLine & _
                  "This is line 4"
    
        On Error Resume Next
        With OutMail
            .To = Email@Domain.com		'Email Address (can be a cell reference)
            .CC = ""
            .BCC = ""
            .Subject = "This is the Subject line"
            .Body = strbody 
            '.Attachments.Add ("C:\test.txt") 	'You can add a file like this
            .Display  					 'or use .Send
        End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub
    any problems give me a shout =D
    This is quite good but what i need is to forward all mails saved in a folder to a different recipient with the attachments on the mails.I find it difficult to do and the above solution did not serve the purpose as attachments are sent from the hard drive location and not from the saved mails. Please help me to forward all mails in a saved folder with attachments if any.

  2. #2
    Junior Member
    Join Date
    Sep 2012
    Posts
    8
    Rep Power
    0
    you could add the mail that you want to forward to the attachments.

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    9
    Rep Power
    0

    Unhappy Forward outlook mails with excel VBA

    Hi,

    Thank you for the reply...but let me expand the question for your better understanding.

    I have copied some mails from outlook inbox to a folder. Some mails are with attachments and some are without. I need to automate it with excel vba to forward those mails to an email ID that i provide in one cell of excel sheet. I need to forward the mails to keep the format and attachments unchanged. Please help me to solve the problem as it's a project I am doing and having problem solving it on time.

    Regards,
    Malay

Similar Threads

  1. Replies: 2
    Last Post: 05-23-2013, 08:08 AM
  2. Replies: 1
    Last Post: 05-22-2013, 01:50 PM
  3. How To Send Outlook Email Using VBA
    By mfaisalrazzak in forum Excel Help
    Replies: 7
    Last Post: 03-03-2013, 03:09 AM
  4. Send Mail Using VBA In Excel And Attach Files
    By macenmin in forum Excel Help
    Replies: 1
    Last Post: 08-03-2012, 01:03 AM
  5. Send Lotus Notes Email Using VBA
    By ramakrishnan in forum Excel Help
    Replies: 1
    Last Post: 09-08-2011, 09:00 AM

Posting Permissions

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