Results 1 to 8 of 8

Need help getting excel to send automatic emails based on cell value

Threaded View

Quito Need help getting excel to... 08-08-2014, 01:00 PM
judgeh59 Re: Need help getting excel... 08-08-2014, 03:40 PM
Quito Re: Need help getting excel... 08-08-2014, 04:21 PM
judgeh59 Re: Need help getting excel... 08-08-2014, 04:25 PM
Quito Re: Need help getting excel... 08-08-2014, 04:35 PM
judgeh59 Re: Need help getting excel... 08-08-2014, 04:49 PM
Quito Re: Need help getting excel... 08-08-2014, 06:54 PM
Quito Re: Need help getting excel... 08-11-2014, 07:09 AM
  1. #1
    Registered User
    Join Date
    06-11-2014
    Posts
    5

    Question Need help getting excel to send automatic emails based on cell value

    Ticket Spreadsheet.xlsx

    I have looked at various threads and whilst i can find similar solutions none are working

    I want a ticketing system that automatically sends an email containing references to the address in column I when the corresponding cell B is changed to 'IN PROGRESS' then another (different email) when it is changed to resolved.

    I want a MsgBox to appear asking: 'Would you like to email the customer?' Y/N so i can choose not to send the email. i want excel to just directly send the email via the exchange network IF POSSIBLE and not open outlook email; however i would be happy to run it through Outlook if it makes this work.



    So when column B changes to 'IN PROGRESS' an message box appears.

    If Yes is clicked an email is sent:

    Email Subject: Ticket Number [COLUMN A] for [COLUMN J]

    Email Msg: Thanks for returning your [COLUMN J] your ticket number is [COLUMN A] please quote this on all future emails. We aim to resolve this by [COLUMN C + 7 DAYS]. Thank You.


    When column B is changed to 'RESOLVED' then it should send another email out:

    Email Subject: Ticket Number [COLUMN A] for [COLUMN J] - RESOLVED

    Email Msg: Your issue with your [COLUMN J], ticket number [COLUMN A] has now been resolved. Thank You.


    My code is probably miles away from being right:
    Private Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
    ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long
    
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
        Dim lngResponse As Long
        Dim URL As String, strEmail As String, strSubject As String, strBody As String
        If Left(Target.Address, 2) = "$B" Then
            If Target.Value =”IN PROGRESS”. Value Then
                lngResponse = MsgBox("Would you like to email the customer?", vbYesNo)
                If lngResponse = vbYes Then
                    strEmail = Range("$I" & Right(Target.Address, 2)).Value
                    strSubject = "Ticket Number " & Range("$A" & Right(Target.Address, 2)).Value & "for " & Range("$J" & Right(Target.Address, 2)).Value
                    strSubject = Application.WorksheetFunction.Substitute(strSubject, " ", "%20")
                   strBody = “Thanks for returning your “  & Range("$J" & Right(Target.Address, 2)).Value & “your ticket number is“ & Range("$A" & Right(Target.Address, 2)).Value & “please quote this on all future emails. We aim to resolve by “& Range("$D" & Right(Target.Address, 2)).Value & “. Thank You.”
    strURL = "mailto:" & strEmail & "?subject=" & strSubject
                    ShellExecute 0&, vbNullString, strURL, vbNullString, vbNullString, vbNormalFocus
    debugs:
    If Err.Description <> "" Then MsgBox Err.Description
                End If
            End If
        End If
    Exit Sub
            If Target.Value =”RESOLVED”. Value Then
                lngResponse = MsgBox("Would you like to email the customer?", vbYesNo)
                If lngResponse = vbYes Then
                    strEmail = Range("$I" & Right(Target.Address, 2)).Value
                    strSubject = "Ticket Number " & Range("$A" & Right(Target.Address, 2)).Value & "for " & Range("$J" & Right(Target.Address, 2)).Value & “- RESOLVED”
                    strSubject = Application.WorksheetFunction.Substitute(strSubject, " ", "%20")
                   strBody = “Your issue with your “  & Range("$J" & Right(Target.Address, 2)).Value & “, ticket number “ & Range("$A" & Right(Target.Address, 2)).Value & “has now been resolved. Thank You.”
    strURL = "mailto:" & strEmail & "?subject=" & strSubject
                    ShellExecute 0&, vbNullString, strURL, vbNullString, vbNullString, vbNormalFocus
    debugs:
    If Err.Description <> "" Then MsgBox Err.Description
                End If
            End If
        End If
    End Sub

    Thanks in advance.
    Last edited by Quito; 08-11-2014 at 07:13 AM. Reason: Added SOLVED prefix

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 12-19-2014, 11:28 AM
  2. [SOLVED] How do I enable Excel 2007 to send automatic emails to outlook
    By Joe McCabe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2014, 09:26 AM
  3. VBA code to send automatic emails via outlook based on deadline
    By Britny in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-05-2013, 10:08 AM
  4. Send automatic emails from excel.v2
    By JasonHopkins in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2012, 11:26 AM
  5. Send automatic emails from excel
    By JasonHopkins in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-09-2012, 08:06 AM

Tags for this Thread

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