+ Reply to Thread
Results 1 to 8 of 8

macro which sends email to few receipients with a standard message

  1. #1
    Registered User
    Join Date
    04-23-2008
    Posts
    50

    macro which sends email to few receipients with a standard message

    Hello,
    Does anyone could help me to create VBA code? I would need to create a button with a macro which lets people to send a standard message: ''Hello,
    I would like to notify you there is another feedback message in the database'' to few email addresses (''[email protected], [email protected] and [email protected]''). The subject of the message: ''notification''
    Thank you.


  2. #2
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: macro which sends email to few receipients with a standard message

    are you emailing FROM outlook? If you are I can give you a code. but only works if your originating from Outlook email.

  3. #3
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: macro which sends email to few receipients with a standard message

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: macro which sends email to few receipients with a standard message

    and just fill in the "" with what you want. then assign it to a button.

  5. #5
    Registered User
    Join Date
    04-23-2008
    Posts
    50

    Re: macro which sends email to few receipients with a standard message

    Many thanks! Would you be able to alter the below code so it shows the ready email in Outlook and i just need to press send? I would like to have a few receipents: [email protected] and [email protected]

    I really appreciate your help.

    Sub Mail_ActiveSheet()
    'Working in Excel 2000-2013
    'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
    Dim FileExtStr As String
    Dim FileFormatNum As Long
    Dim Sourcewb As Workbook
    Dim Destwb As Workbook
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim OutApp As Object
    Dim OutMail As Object

    With Application
    .ScreenUpdating = False
    .EnableEvents = False
    End With

    Set Sourcewb = ActiveWorkbook

    'Copy the ActiveSheet to a new workbook
    ActiveSheet.Copy
    Set Destwb = ActiveWorkbook

    'Determine the Excel version and file extension/format
    With Destwb
    If Val(Application.Version) < 12 Then
    'You use Excel 97-2003
    FileExtStr = ".xls": FileFormatNum = -4143
    Else
    'You use Excel 2007-2013
    Select Case Sourcewb.FileFormat
    Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
    Case 52:
    If .HasVBProject Then
    FileExtStr = ".xlsm": FileFormatNum = 52
    Else
    FileExtStr = ".xlsx": FileFormatNum = 51
    End If
    Case 56: FileExtStr = ".xls": FileFormatNum = 56
    Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
    End Select
    End If
    End With

    ' 'Change all cells in the worksheet to values if you want
    ' With Destwb.Sheets(1).UsedRange
    ' .Cells.Copy
    ' .Cells.PasteSpecial xlPasteValues
    ' .Cells(1).Select
    ' End With
    ' Application.CutCopyMode = False

    'Save the new workbook/Mail it/Delete it
    TempFilePath = Environ$("temp") & "\"
    TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    With Destwb
    .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
    On Error Resume Next
    With OutMail
    .to = "[email protected]"
    .CC = ""
    .BCC = ""
    .Subject = "This is the Subject line"
    .Body = "Hi there"
    .Attachments.Add Destwb.FullName
    'You can add other files also like this
    '.Attachments.Add ("C:\test.txt")
    .Send 'or use .Display
    End With
    On Error GoTo 0
    .Close savechanges:=False
    End With

    'Delete the file you have send
    Kill TempFilePath & TempFileName & FileExtStr

    Set OutMail = Nothing
    Set OutApp = Nothing

    With Application
    .ScreenUpdating = True
    .EnableEvents = True
    End With
    End Sub

  6. #6
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: macro which sends email to few receipients with a standard message

    the code I gave you literally will make the button send an email to whoever you want saying what you want with a click of the button.

    I have no idea what all your other code is for :0

  7. #7
    Registered User
    Join Date
    04-23-2008
    Posts
    50

    Re: macro which sends email to few receipients with a standard message

    The above code sends an email with attachement (active worksheet) right away. I would need the user to see the content of email before it gets send.

  8. #8
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: macro which sends email to few receipients with a standard message

    ah k im afraid that's above my know how. sorry

+ 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. HELP! Need help with macro that automatically sends email when...
    By KngCharming in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-28-2013, 01:01 PM
  2. Email loop only sends first email from outlook.
    By vamosj in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-16-2013, 04:33 PM
  3. VBS/OutMail script and macro sends email message twice
    By Andrew_Harris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2013, 08:57 PM
  4. Macro that sends email automatically once a week?
    By GTfan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2012, 02:44 PM
  5. A macro that looks up a email from sheet2 and sends email
    By AdderLee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2012, 02:24 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