?
Solved

Excel VBA Send Text Message

Posted on 2011-02-19
5
Medium Priority
?
1,339 Views
Last Modified: 2013-12-18
Using Outlook email how to send a text message (not a workbook)
I tried the code below but I get "Object Required" error
Regards
Brian
Sub DoneMessage()
    Options.SendMailAttach = False
    ActiveWorkbook.SendMail _
    Recipients:=[TenDigitPhoneNumber] _
        & "@" &   [TextMessageDomain],  _
    Subject:=[SubjectLine]
End Sub

Open in new window

0
Comment
Question by:canesbr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34934132
Are you planning to send the SMS? Are you planning to use MOSA?

Sid
0
 
LVL 13

Assisted Solution

by:George K.
George K. earned 2000 total points
ID: 34934145
Try this code


 Dim myrange As Range
    Dim myApp As Object
    Dim myMail As Object

    Set myrange = Nothing

     '...    for visible cells selected
    Set myrange = Selection.SpecialCells(xlCellTypeVisible)

   
    If myrange Is Nothing Then
        MsgBox "select a range" ", vbOKOnly
        Exit Sub
    End If

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

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



 With myMail
        .To = "someone@hotmail.coml"
        .CC = ""
        .BCC = ""
        .Subject = "A Subject here"
' in the follwing you can also add some simple text
        .HTMLBody = RangetoHTML(myrange )
        .Send  
    End With
.....
0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 34934155
1st: Options is undefined
2nd: From what i've read, SendMailAttach seams to be linked to Word Interop... (http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.options.sendmailattach(office.11).aspx)

Try to dump that line and see if it does what you want.
0
 

Accepted Solution

by:
canesbr earned 0 total points
ID: 34934656
@georgekl
Thanks - just fixed typo
You had Set myMail = OutApp.CreateItem(0)
Should be Set myMail = myApp.CreateItem(0)
Code below works fine.
Regards
Brian
Sub SendTextMessage()
    Dim myApp As Object
    Dim myMail As Object
    Set myApp = CreateObject("Outlook.Application")
    Set myMail = myApp.CreateItem(0)
    With myMail
        .To = [MessageAddress]
        .CC = ""
        .BCC = ""
        .Subject = [MessageSubject]
        .HTMLBody = [MessageText]
        .Send
    End With
End Sub

Open in new window

0
 

Author Closing Comment

by:canesbr
ID: 34968292
Nice.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question