Results 1 to 7 of 7

Thread: Outlook: MailItem formating

  1. #1

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    59

    Outlook: MailItem formating

    Hi
    Can i programmically (VBA) add controls to the Outlooks MailItem ?
    (or any of outlook defined items)

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook: MailItem formating

    What do you mean "controls"? Do you mean add menus or toolbar buttons?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    59

    Re: Outlook: MailItem formating

    yes.
    i would like to create my mail form. The form should contain all the MailItem fields with there functionlality and toolbars. In addition, it will contain some buttons and toolbars that i'll write.

    10x

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook: MailItem formating

    It may be easier to just add a menu or toolbar button to Outlooks new mail message form then creating one from scratch.
    You know you can create an Add-In for Outlook that may be easier and more professional looking.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    59

    Re: Outlook: MailItem formating

    that is the question..
    How can i programmically add some buttons, text boxes to an outlook MailItem?
    I can design outlook mail message form from menu Tools->Form->Design, and choose Message, but in this case i don't know how can i access this form from VBA Editor, so i will be able to view all fields (include those i've added).
    So i whould like to write some CreateMailItemTemplate routine, that will take MailItem as a basic and will add some buttons to it.
    I do not whant the default MailItem to change.
    10x

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook: MailItem formating

    Ok, if you do this in Outlook VBA then the code should not invoke any security prompts.
    You need to create a NewInspector event and manipulate the Inspector object as you desire.

    So what do you actually want to add so I can write an outline of code for you?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    59

    Re: Outlook: MailItem formating

    thanks...
    1. I've already added my control bar, that has "MySend" command button.
    say i want to add one OptionButton to a outlook MailItem Form.
    In the "OnAction" property of "MySend" button i'm getting all field values that MailItem has (to,cc,bcc,subject..), and i want to be able to get the added OptionButton value too.
    here some of my code:

    Private Sub sSendButtonOnClick()
    On Error GoTo ErrorHandler

    Dim appOutlook As Outlook.Application
    Dim ins As Outlook.Inspector
    Dim msg As Outlook.MailItem
    ' Dim strMessage As String
    Dim outMsgStr As String

    'Determine whether Outlook is running
    Set appOutlook = GetObject(, "Outlook.Application")

    'Determine whether an Outlook item is open in an Inspector
    Set ins = appOutlook.ActiveInspector
    If ins Is Nothing Then
    MsgBox "No Outlook item is open"
    GoTo ErrorHandlerExit
    Else
    Debug.Print "Current item class: " & ins.CurrentItem.Class
    End If

    'Determine class of currently open Outlook item
    If ins.CurrentItem.Class <> olMail Then
    'Current item is not a mail item
    MsgBox "No mail item is open"
    GoTo ErrorHandlerExit

    ElseIf ins.CurrentItem.Class = olMail Then
    'Current item is a mail item
    Set msg = ins.CurrentItem

    'Constructing the output message
    outMsgStr = outMsgStr & msg.To & ","
    outMsgStr = outMsgStr & msg.CC & ","
    outMsgStr = outMsgStr & msg.BCC & ","
    outMsgStr = outMsgStr & msg.Subject & ","
    outMsgStr = outMsgStr & msg.Body

    'sending output message
    MsgBox outMsgStr
    .....
    End Sub

    2. One more question:
    I want to translate a string, looking like "to,cc,bcc,subject,body" to the mail veiw and put it to Inbox folder.
    Creating the MailItem object, setting the fields, saving and than moving it to Inbox folder doesn't works
    the outlook doesn't recognize it as recieved mail, it shows the mail as mail to send
    (all the send options are available, and reply aren't)
    Is there any way that i can make myMessages look like the outlook ones. (Including the changes of Standard ToolBar Buttons (reply,forward..)) ??

Posting Permissions

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



Click Here to Expand Forum to Full Width