sendmessage & setting importance

Badvoc

Registered User.
Local time
Today, 22:56
Joined
Apr 22, 2009
Messages
69
Hi
Im using sendmessage as a public function to send an email, I'd like to let the user set the importance of the message.
Iv tried changing the code where it states the email importance to:

.Importance = ([Forms]![frmTRupdate]![text101])

Text101 is unbound combo on form TRupdate with olimportanceLow;olimportanceNormal;olImportanceHigh as the value list.

But this is not working.

Any ideas?

Heres the code in full
Code:
Public Function ASiSendMessage() '(Optional AttachmentPath As String)
   Dim objOutlook As Outlook.Application
   Dim objOutlookMsg As Outlook.MailItem
   Dim objOutlookRecip As Outlook.Recipient
   Dim objOutlookAttach As Outlook.Attachment
   Dim nl As String
 
    nl = vbNewLine & vbNewLine
 
   On Error GoTo ErrorMsgs
 
 
 
   ' Create the Outlook session.
   Set objOutlook = CreateObject("Outlook.Application")
   ' Create the message.
   Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
   With objOutlookMsg
      ' Add the To recipient(s) to the message. Substitute
      ' your names here.
     'Set objOutlookRecip = ([Forms!form12.Combo11])
     Set objOutlookRecip = .Recipients.Add([Forms]![frmTRUpdate]![AssignedEngineer].Column(0))
          objOutlookRecip.Type = olTo
      ' Add the CC recipient(s) to the message.
      ' Set the Subject, Body, and Importance of the message.
      .Subject = "A new Technical Request, number " & ([Forms]![frmTRUpdate]![TR number]) & " has been assigned to you"
      .Body = "Customer:  " & ([Forms]![frmTRUpdate]![CustomerType]) & nl & _
      "The subject of the TR is:  " & ([Forms]![frmTRUpdate]![Subject])
      .Importance = [Forms]![frmTRUpdate]![Text109]
            .Send
 
   End With
   Set objOutlookMsg = Nothing
   Set objOutlook = Nothing
   Set objOutlookRecip = Nothing
   Set objOutlookAttach = Nothing
ErrorMsgs:
   If Err.Number = "287" Then
      MsgBox "You clicked No to the Outlook security warning. Rerun the procedure and click Yes to access e-mail addresses to send your message. For more information, see the document at [URL]http://www.microsoft.com/office/previous/outlook/downloads/security.asp[/URL]. "
 
   Else
      MsgBox "E-mail sent"
 
   End If
End Function
 
'olImportanceLow' is a member of one of Outlook's enumerated types and is thus an identifier that evaluates to a number.
The Value property of a combo, on the other hand, is a string. This line...
Code:
.Importance = ([Forms]![frmTRupdate]![text101])
...fails because '.Importance' is a number and '[Forms]![frmTRupdate]![text101]' is not.
You need a combo with two columns where the Value property returns a number and the ColumnWidths property only allows display of the text.
Research the ColumnCount, ColumnWidths, BoundColumn, RowSource, and RowSourceType properties of the Combobox Class. And you can determine the actual values of the olImportance??? identifiers using the object browser, or typing...
Code:
? olImportanceHigh
...in the immediate window.
 
ah, easy when you know how.
thanks
 

Users who are viewing this thread

Back
Top Bottom