+ Reply to Thread
Results 1 to 2 of 2

Mail send using outlook express

Hybrid View

  1. #1
    Registered User
    Join Date
    03-16-2014
    Location
    Bangalore
    MS-Off Ver
    Excel 2016
    Posts
    46

    Mail send using outlook express

    Im using the below code for making a mail directly from my excel file. This program works perfectly on using the Microsoft Outlook.
    The issue is that in office im using Outlook Express (on Windows XP). This program doesnt work there.
    It is a request please help me in making it work with Outlook Express even if it stops working with Microsoft Outlook.
    Thanks in advance.


    Sub Mail_Selection()
    
        Dim Source As Range
        Dim Dest As Workbook
        Dim wb As Workbook
        Dim TempFilePath As String
        Dim TempFileName As String
        Dim FileExtStr As String
        Dim FileFormatNum As Long
        Dim OutApp As Object
        Dim OutMail As Object
    
        Set Source = Nothing
        On Error Resume Next
        Set Source = Selection.SpecialCells(xlCellTypeVisible)
        On Error GoTo 0
    
        If Source Is Nothing Then
            MsgBox "The source is not a range or the sheet is protected, please correct and try again.", vbOKOnly
            Exit Sub
        End If
    
       
    
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        Set wb = ActiveWorkbook
        Set Dest = Workbooks.Add(xlWBATWorksheet)
    
        Source.Copy
        With Dest.Sheets(1)
            .Cells(1).PasteSpecial Paste:=8
            .Cells(1).PasteSpecial Paste:=xlPasteValues
            .Cells(1).PasteSpecial Paste:=xlPasteFormats
            .Cells(1).Select
            Application.CutCopyMode = False
            
        End With
    
        TempFilePath = Environ$("temp") & "\"
        TempFileName = "Order Details for- " & Selection.Cells(2, 2)
        If Val(Application.Version) < 12 Then
            'You use Excel 97-2003
            FileExtStr = ".xls": FileFormatNum = -4143
        Else
            'You use Excel 2007-2013
            FileExtStr = ".xlsx": FileFormatNum = 51
        End If
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
        With Dest
            .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
            On Error Resume Next
            With OutMail
                .to = ""
                .CC = ""
                .BCC = ""
                .Subject = "Order of " & Selection.Cells(2, 3)
                .Body = "Order:" & vbNewLine & _
                        "Date: " & Selection.Cells(2, 2) & vbNewLine & _
                        "Manufacturer Name: " & Selection.Cells(2, 1) & vbNewLine & _
                        "Party Name: " & Selection.Cells(2, 3) & vbNewLine & _
                        "Quantity: " & Selection.Cells(2, 4) & vbNewLine & _
                        "Order Details: " & Selection.Cells(2, 5) & vbNewLine & _
                        "Ex/Deld: " & vbNewLine & _
                        "Payment: " & Selection.Cells(2, 9) & " Day(s)" & vbNewLine & _
                        "wb: " & Selection.Cells(2, 6) & vbNewLine & vbNewLine & vbNewLine & _
                        "Conditions : Please give items wise details along with invoice." & vbNewLine & vbNewLine & vbNewLine & vbNewLine & _
                        "From," & vbNewLine & _
                        "Yash Agarwal" & vbNewLine & _
                        "Bangalore."
                        
                
                'You can add other files also like this
                '.Attachments.Add ("C:\test.txt")
                .Display   'or use .Display
            End With
            On Error GoTo 0
            .Close savechanges:=False
        End With
    
        Kill TempFilePath & TempFileName & FileExtStr
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    
        With Application
            .ScreenUpdating = True
            .EnableEvents = True
        End With
    End Sub
    Last edited by yashagarwal; 05-31-2014 at 01:13 PM.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,621

    Re: Mail send using outlook express

    There is an add-in by Ron de Bruin at this place. Code is also available

+ 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. send emails via outlook express
    By markstevenson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2010, 12:23 PM
  2. Outlook Express - how to send value of a cell...
    By bondcrash in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2006, 11:55 AM
  3. How can I use Outlook express to send mail rather than Outlook by VBA code
    By new.microsoft.com in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2005, 11:05 AM
  4. [SOLVED] How can I use Outlook express to send mail rather than Outlook by VBA code
    By new.microsoft.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2005, 08:05 AM
  5. [SOLVED] Send to Outlook 2000 not Outlook Express
    By Jimbo in forum Excel General
    Replies: 2
    Last Post: 01-04-2005, 05:06 PM

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