Results 1 to 11 of 11

Thread: Sending e-mails from Access using Outlook [resolved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Sending e-mails from Access using Outlook [resolved]

    Hi this is a problem which I'm realy stuck on. For a bit of background we use Exchange 2003 as are mailserver and have outlook 2000 clients.
    I have an e-mailer program which takes an e-mail it recives and forward it out again. The problem is we have a client complaing saying he only wants the e-mail we send him to be in plain text. If I send the program straight from Outlook it's fine, but for some reson when I use the below code to send an e-mail it's sent as both plain text and HTML, anyone now how to change this.

    VB Code:
    1. Private Function sendemail(todest As String, subject As String, body As String) As Boolean
    2. On Error GoTo sendwarning:
    3. Dim fnam As String
    4. Dim loopcounter As Integer
    5. loopcounter = 0
    6.  
    7. Set objMailitem = objApp.CreateItem(olMailItem)
    8. If addatt Then
    9. Set myatts = myitem.Attachments
    10.         If myatts.Count > 0 Then
    11.             Set myatts = myitem.Attachments
    12.             Set objattachments = objMailitem.Attachments
    13.            
    14.             Do While loopcounter < myatts.Count
    15.                 loopcounter = loopcounter + 1
    16.                 Set myatt = myatts(loopcounter)
    17.                 fnam = myatt.FileName
    18.                 If Mid(fnam, 1, 4) = "Page" Then
    19.                     fnam = Mid(fnam, 1, 11)
    20.                 End If
    21.                 myatt.SaveAsFile fnam
    22.                
    23.                 objattachments.Add (fnam)
    24.    
    25.             Loop
    26.        
    27.         Else
    28.             Set myatt = Nothing
    29.         End If
    30. End If
    31. objMailitem.To = todest
    32. objMailitem.subject = subject
    33. objMailitem.body = body
    34. objMailitem.Send
    35. sendemail = True
    36. Exit Function
    37.  
    38. sendwarning:
    39. sendemail = False
    40.  
    41. End Function
    Last edited by Oliver1; Feb 1st, 2005 at 10:50 AM.

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Sending e-mails from Access using Outlook

    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Re: Sending e-mails from Access using Outlook [resolved]

    Thanks, is annoying when you can't figure something out. Should have done a search first (bad me) but didn't think it would be the kind of problm anyone else would have.

    Thanks again

  4. #4
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Sending e-mails from Access using Outlook [resolved]

    No, it's not your fault. The Office ActiveX EXE objects are extremely poorly documented. You have to dig hard and long to get any info on the internals of these objects.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

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

    Re: Sending e-mails from Access using Outlook [resolved]

    Dave, instead of setting it to 1, wouldnt it be easier reading to set it to the const. - olFormatHTML ?
    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

  6. #6
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Sending e-mails from Access using Outlook [resolved]

    Quote Originally Posted by RobDog888
    Dave, instead of setting it to 1, wouldnt it be easier reading to set it to the const. - olFormatHTML ?
    Totally. But sometimes you don't get constants in VB, and I couldn't tell by the MSDN documentation so I just played it safe. Definately use constants if they are available to you.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

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

    Re: Sending e-mails from Access using Outlook [resolved]

    Thats what I thought. You dont get the const.'s when you are using
    VBScript or are using late binding
    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

  8. #8
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Sending e-mails from Access using Outlook [resolved]

    P.S. the MSDN docs say to use CdoBodyFormatText. I think its different in the VB IDE.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

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

    Re: Sending e-mails from Access using Outlook [resolved]

    Depends on how his module code is. If he has a reference to Outlook added
    then use the olFormatHTML. If not then its Access' CDO default reference, I
    think is how it is?
    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

  10. #10
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Sending e-mails from Access using Outlook [resolved]

    ahem * cough * ahem - he wants plain text...
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

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

    Re: Sending e-mails from Access using Outlook [resolved]

    Doh! Thats right. olFormatPlain it is then.
    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

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