+ Reply to Thread
Results 1 to 7 of 7

VBA to mail in Outlook

  1. #1
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267

    VBA to mail in Outlook

    I have a program right now where the user inputs whatever information they want and the email gets sent through Outlook with the subject, recipient, body, etc. of whatever they specify. Is there a way to make it automatically mark the outgoing email with high importance? Like the little exclamation point that Outlook has?

    Thanks,
    Will

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Will,

    Set the MailItem object Importance property to olImportanceHigh (constant value 0f 2).

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    That's a little beyond me I am afraid. I got the code from this site and I think actually from you, Leith. Do you have a snippet of code I can put in somewhere?

    Thanks,
    Will

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Will,

    If you post the code, I'll amend it for you. If you don't have the code, let me know what you need and I'll write a macro.

    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    Hi Leith,
    This code probably looks familiar to you because I am pretty sure you wrote it. Anways, what do I put and where do I put it to mark the outgoing email with high importance?

    Private Sub CommandButton1_Click()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strto As String, strcc As String, strbcc As String
    Dim strsub As String, strbody As String
    Dim PolicyNumber As String

    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)

    strto = "[email protected]"
    'I didn't use the actual address I use

    If Range("C21") <> "" Then
    PolicyNumber = Range("C21")
    strcc = "[email protected]"
    strbcc = ""
    strsub = ProbTopicBox & ", " & PolicyNumber
    strbody = "Agent Number:" & AgentNumberBox & vbCrLf & "Agency Name: " & AgencyBox & vbCrLf & "Agent:" & AgentBox & vbCrLf & vbCrLf & ProblemBox
    Else
    strcc = "[email protected]
    strbcc = ""
    strsub = ProbTopicBox & " (not policy specific)"
    strbody = "Agent Number:" & AgentNumberBox & vbCrLf & "Agency Name: " & AgencyBox & vbCrLf & "Agent:" & AgentBox & vbCrLf & vbCrLf & ProblemBox
    End If

    With OutMail
    .To = strto
    .CC = strcc
    .BCC = strbcc
    .Subject = strsub
    .Body = strbody
    .Send
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
    Me.Hide
    End Sub
    Thanks a lot, man.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Will,

    The property is set in the mail item, your object variable OutMail. Copy and paste this into your macro to replace the old code section for OutMail.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  7. #7
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    Worked perfectly, thank you so much! Where do you learn this stuff?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1