Advertisement
Advertisement
| 07.13.2008 at 10:38AM PDT, ID: 23561021 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: |
Option Explicit
Public oSession As Mapi.Session ****Can't find project or library
Public oMessage As Mapi.Message
Public oRecip As Mapi.Recipient
Public MessageID As String
Private Sub Form_Load()
Set oSession = CreateObject("MAPI.Session")
If oSession Is Nothing Then
MsgBox "Could not create Mapi Session", vbOKOnly, "VBSendRTF"
End
End If
oSession.Logon
CreateNewMessage
End Sub
Private Sub Form_UnLoad(Cancel As Integer)
If Not oMessage Is Nothing Then
oMessage.Delete
Set oMessage = Nothing
End If
If Not oSession Is Nothing Then
oSession.Logoff
Set oSession = Nothing
End If
End Sub
Private Sub cmdBold_Click()
RTFMessage.SelBold = Not RTFMessage.SelBold
RTFMessage.SetFocus
End Sub
Private Sub cmdItalic_Click()
RTFMessage.SelItalic = Not RTFMessage.SelItalic
RTFMessage.SetFocus
End Sub
Private Sub cmdSendMessage_Click()
Dim oMsgFilter As Mapi.MessageFilter
Dim bRet As Integer
'Set Subject
oMessage.Subject = txtSubject.Text
'Verify Recipient specified
If IsEmpty(txtSendTo.Text) Then
MsgBox "Please specify email name in 'Send To' text box", vbOKOnly, "VBSendRTF"
Return
End If
'Set Recipient
Set oRecip = oMessage.Recipients.Add
oRecip.Name = txtSendTo.Text
oRecip.Type = ActMsgTo
oRecip.Resolve
'Save the message
oMessage.Update
'Set the RTF property
bRet = WriteRTF(oSession.Name, oMessage.ID, _
oMessage.StoreID, RTFMessage.TextRTF)
If Not bRet = 0 Then
MsgBox "RTF Property not stored successfully!", vbOKOnly, "VBSendRTF Warning"
End If
' Retrieve the message again, now that it has changed
Set oMessage = Nothing
Set oMsgFilter = oSession.Outbox.Messages.Filter
oMsgFilter.Fields(ActMsgPR_ENTRYID) = MessageID
Set oMessage = oSession.Outbox.Messages.GetFirst
' Clear the Message Filters
Set oMsgFilter = Nothing
Set oSession.Outbox.Messages.Filter = Nothing
' Send the message
oMessage.Send
MsgBox "Message Sent"
CreateNewMessage
End Sub
Sub CreateNewMessage()
Set oMessage = oSession.Outbox.Messages.Add
If oMessage Is Nothing Then
MsgBox "Could not create Message", vbOKOnly, "VBSendRTF"
End
End If
oMessage.Update
MessageID = oMessage.ID
RTFMessage.Text = "Message"
txtSubject.Text = "Subject"
txtSendTo.Text = "EmailName"
End Sub
Private Sub cmdCopyMessage_Click()
Dim oMsgFilter As Mapi.MessageFilter
Dim bRet As Integer
Dim MsgRTF As String
'Set Subject
Dim oSrcMessage As Message
Set oSrcMessage = oSession.Inbox.Messages(1)
'Save the message
oSrcMessage.Update
' Initialize the variable before passing it to the DLL
' The length of this variable will be the maximum length returned by the DLL
MsgRTF = Space(5000)
'Set the RTF property
bRet = ReadRTF(oSession.Name, oSrcMessage.ID, _
oSrcMessage.StoreID, MsgRTF)
If Not bRet = 0 Then
MsgBox "RTF Property not copied successfully!" & Chr(13) _
& "Error: " & Hex$(bRet), vbOKOnly, "VBMapiRTF Warning"
Else
RTFMessage.TextRTF = MsgRTF ' Show the text in our RichEdit control
End If
txtSubject.Text = oSrcMessage.Subject
Set oSrcMessage = Nothing
End Sub
|