Results 1 to 2 of 2

[SOLVED] How to Verify that the contents of the cell is an Email Addy

Threaded View

  1. #1
    Registered User
    Join Date
    01-10-2011
    Location
    Lake Havasu City, AZ
    MS-Off Ver
    Excel 2010
    Posts
    4

    [SOLVED] How to Verify that the contents of the cell is an Email Addy

    As there was no response about using an external .msg file in order to send information from within Excel, I will have to manage with the attached.

    I do, however, need help to verify that the contents of the cell is an Email Addy.
    Currently I can only test to see if it's blank.

    If anyone has better suggestions about using a .msg file OR how to check that the contents are in email@address.com format, PLEASE send me a note.

    Scott
    mailto:sellen@aol.com

    ~~~~~~~~~~~~~~~~~~
    Sub Email_standard_Product_info()
    '
    ' Email_standard_Product_info Macro
    ' This macro will read the current cell (which should contain an email@address.info type of contents) and then send a message and standard product literature to that addy.
    '
    ' Keyboard Shortcut: Ctrl+m
    '
    ' Macro recorded 01-11-2011 By Scott Ellenwood
    '
        'Dimension the Variables as Strings or Objects
        Dim OutApp As Object
        Dim OutMail As Object
        Dim ToAddy As String
        Dim Signature As String
        Dim Bodytext As String
        
        'Copy the contents of the current cell as the TO address. Needs to be in name@whatever.com format
        ToAddy = ActiveCell.Value
    
        Set OutApp = CreateObject("Outlook.Application")
        OutApp.Session.Logon
        Set OutMail = OutApp.CreateItem(0)
        
        'Designate the text etc that will comprise the body of the message or signature.
        '   How to bold it??
            Bodytext = "Dear Sir or Madam -" & vbCrLf & vbCrLf & _
                "Attached, Please Blah Blah Blah"& vbCrLf & _
                "Regards,"
                  
        'Now Designating the contents of the Signature using the following text.
            Signature = "Wonderful Little Me" & vbCrLf & _
                "Outside Sales And Development"
              
        
        'Test to make certain the Email TO value is not blank
        If ActiveCell.Value = "" Then
            GoTo ErrorTrap1
        Else
        End If
    
        On Error Resume Next
        With OutMail
                .To = ToAddy
                .CC = ""
                .BCC = ""
                .Subject = "Product Information Enclosed"
                .Body = Bodytext & vbCrLf & Signature
                .Attachments.Add "C:\other_stuff.pdf"
                .Send
                .Close SaveChanges:=False
        End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
        
        With Application
            .ScreenUpdating = True
            .EnableEvents = False
    
        End With
        MsgBox "Email Sent to [ " & ToAddy & " ]. Have a nice day."
        GoTo EndofMacro
        
    ErrorTrap1:
        MsgBox "Sorry, Charlie. Blank Cells Ain't gonna work."
        
    EndofMacro:
    End Sub
    
    Function GetBoiler(ByVal sFile As String) As String
    Dim fso As Object
    Dim ts As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
    GetBoiler = ts.readall
    ts.Close
    End Function
    Last edited by sellenwood; 01-12-2011 at 10:46 AM. Reason: Added Code tags and Edited Title

Thread Information

Users Browsing this Thread

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

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