Solved

Excel VBA Send Text Message

Posted on 2011-02-19
5
1,331 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 500 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:cdebel
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

734 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