Results 1 to 10 of 18

Thread: Excel VBA to Attach File And Automatically Send Email

Threaded View

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

    The code you provided can open the ".msg" file in forward mode but "From.." option in outlook is showing the person's name from whom the mail has been originally received. This is why the mail cannot be forwarded clicking the send button. Please tell me how to change the original "From.." to the current sender's mail id...

    Code:
    Sub SendMSGFiles()
    
        Dim objItemMSG As Object
        Dim strFolderLocation As String
        Dim objFolder As Object
        Dim strFile As String
        Dim olApp As Object
        
        On Error Resume Next
        Set olApp = GetObject(, "Outlook.Application")
        Err.Clear: On Error GoTo 0: On Error GoTo -1
        If olApp Is Nothing Then
            Set olApp = CreateObject("Outlook.Application")
        End If
        Set objFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Select MSG folder location", 0, "")
        If Not objFolder Is Nothing Then
            strFolderLocation = objFolder.self.Path
        Else
            Exit Sub
        End If
        strFile = Dir(strFolderLocation & "\*.msg")
        While strFile <> ""
            Set objItemMSG = olApp.CreateItemFromTemplate(strFolderLocation & "\" & strFile)
            objItemMSG.To = "abc@xyz.com"
            objItemMSG.Send
            strFile = Dir
        Wend
        
    End Sub
    Last edited by Excel Fox; 07-15-2013 at 09:58 PM. Reason: Code tag added

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
  •