MobileItem Object (Outlook)

Represents a text message item (Short Message Service (SMS) message) or a multimedia message item (Multimedia Messaging Service (MMS) message).

Version Information

Version Added: Outlook 2010

Remarks

The MobileItem object allows you to incorporate mobile messaging into Outlook solutions. In many ways, the MobileItem object is very similar to other Outlook item types. For example, you can use the CreateItem method of the Application object, or the Add method of the Items object for a folder, to create a MobileItem object. You can use the Recipients and Subject properties to specify recipients and a subject for the MobileItem. In other ways, the MobileItem behaves differently. For example, the Send method has a ForceSend parameter that supports sending the item even when the item exceeds the limitations of the service provider.

Depending on the format of the MobileItem and the body format of the message, you can use the Body, HTMLBody, or SMILBody property to specify the message content of the MobileItem.

Use the MobileFormat property to verify whether a MobileItem object is a text message or multimedia message.

Example

The following code example in Visual Basic for Applications (VBA) shows how to create an SMS MobileItem object by using the CreateItem method of the Application object. The code example initializes the Body property of the MobileItem object and displays it in an inspector.

Sub CreateMobileItemSMS() 
 
 Dim olApp As Outlook.Application 
 
 Dim myMobileItem As Outlook.MobileItem 
 
 Set olApp = Outlook.Application 
 
 Set myMobileItem = olApp.CreateItem(olMobileItemSMS) 
 
 myMobileItem.Body = "Text message was created by OM!" 
 
 myMobileItem.Display 
 
End Sub 
 

The following VBA code example shows how to create an MMS MobileItem object in the Inbox folder by using the Add method of the Items object for that folder. The code example initializes the Subject property of the MobileItem object and displays it in an inspector.

Sub AddMobileItem() 
 
 Dim myOlApp As New Outlook.Application 
 
 Dim myNamespace As Outlook.NameSpace 
 
 Dim myItems As Outlook.Items 
 
 Dim myFolder As Outlook.Folder 
 
 Dim myMobileItem As Outlook.MobileItem 
 
 Set myNamespace = myOlApp.GetNamespace("MAPI") 
 
 Set myFolder = _ 
 
 myNamespace.GetDefaultFolder(olFolderInbox) 
 
 Set myItems = myFolder.Items 
 
 Set myMobileItem = myItems.Add("IPM.NOTE.Mobile.MMS") 
 
 myMobileItem.Subject = "My Multimedia Message" 
 
 myMobileItem.Display 
 
End Sub 
 

The following VBA code example shows how to create an MMS MobileItem object by using the CreateItem method of the implicit Outlook Application object. The code example adds an attachment to the MobileItem object and sets the PidTagAttachContentId property of the attachment. The example then initializes the SMILBody property, and saves and displays the MobileItem object.

Sub CreateMobileItemMMS () 
 
 
 
 Dim myMobileItem As MobileItem 
 
 Dim myAttachment, myAttachment1, myAttachment2 As Outlook.Attachment 
 
 Set myMobileItem = CreateItem(olMobileItemMMS) 
 
 Set myAttachment1 = myMobileItem.Attachments.Add("C:\att0.txt", olByValue) 
 
 ' Sets the PidTagAttachContentId property of the attachment. 
 
 myAttachment1.PropertyAccessor.SetProperty "https://schemas.microsoft.com/mapi/proptag/0x3712001F", "att0.txt" 
 
 
 
 myMobileItem.SMILBody = "<?xml version=""1.0"" standalone=""yes""?>" & _ 
 
 "<smil><head><meta name=""author"" content=""MSOfficeOlkOMS""/>" & _ 
 
 "<layout><root-layout width=""128"" height=""128"" background-color=""#000000""/>" & _ 
 
 "<region id=""Image"" left=""0%"" top=""0%"" width=""100%"" height=""75%"" fit=""slice""/>" & _ 
 
 "<region id=""Text"" left=""0%"" top=""75%"" width=""100%"" height=""25%"" fit=""slice""/>" & _ 
 
 "</layout></head><body><par dur=""invalid""><img src=""att1.jpg"" region=""Image""/>" & _ 
 
 "<text src=""att0.txt"" region=""Text""/></par></body></smil>" 
 
 
 
 myMobileItem.Save 
 
 myMobileItem.Display 
 
end sub 
 

See Also

Concepts

Outlook Object Model Reference

MobileItem Object Members