Solved

outlook object help required send email automatically no prompt and plain text format

Posted on 2007-04-03
5
812 Views
Last Modified: 2013-12-20
i am using the outlook object in my vb app and i need to change the body text to plain text and also need to know how to send without outlook promting me when i do the send. I am using the follwoing code

  Set ole_app = CreateObject("Outlook.Application")
    Set ole_item = ole_app.CreateItem(0)
    ole_item.Subject = "My subject"l
    ole_item.TO = "abcd@so and sot"
    ole_item.body = body
 ole_item.Send
    Set ole_item = Nothing

0
Comment
Question by:pele4483
  • 2
5 Comments
 
LVL 27

Expert Comment

by:VBRocks
ID: 18843627
My friend, I'm sorry to tell you this...  but you can't.  So to speak.  MS updated Outlook to throw that prompt every time someone tries to access the application using it's object model, and there is no way around it.

However...  I built an application using the Outlook Redemption object model, and it mirrors MS Outlook's object model, but allows you to send e-mails without getting that very anoying prompt.  It is a very nice tool, very easy to use, with enough documentation to help you out.  You can get more info about it at the following website:

http://www.dimastr.com/redemption/

Good luck!
0
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 50 total points
ID: 18849204
thats not quite correct...
you can use CDO 2.  It may not be quite as simple but it works well. It is installed along with MS Outlook client and can be installed independently i think.



' Done by Robberbaron.
' Last modified : 31.07.06

Private objMsg As Object
Private objConf As Object
Private objFlds As Object

Const sMailServerName = "xyz.com"

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2 'Must use this to use Delivery Notification
Const cdoAnonymous = 0
Const cdoBasic = 1 ' clear text
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay



Public Function SendMail(tcaAddresses() As String, ByVal tcSubject As String, taAttachment() As String, Optional ByVal tcMessage As String = " ") As Boolean

   
    With objMsg
      Set .Configuration = objConf
      lnNumOfRecip = UBound(tcaAddresses, 1)
        'CurDir (goProjProperties.cAppPath)
        For lnCount = 0 To lnNumOfRecip - 1
            If lnCount > 0 Then
                'add a comma
                .To = .To & ","
            End
            .To = .To & Trim(tcaAddresses(lnCount, 0))
        Next
     
      '.to = "test@paulsadowski.com"
      .From = "mail@bornhorstward.com.au"
      .Subject = Space(2) & Trim(tcSubject)
      .TextBody = Space(lnNumOfAtt) & vbCrLf & tcMessage
       'use .HTMLBody to send HTML email.
     
        For lnCount = 0 To lnNumOfAtt - 1
           lcAttName = taAttachment(lnCount)
           .AddAttachment lcAttName
        Next
     
      .fields("urn:schemas:mailheader:disposition-notification-to") = "me@my.com"
      .fields("urn:schemas:mailheader:return-receipt-to") = "me@my.com"
      .DSNOptions = cdoDSNSuccessFailOrDelay
      .fields.Update
      .Send
    End With

    NewMail = True
   Exit Function
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 18852073
Very nice!  I didn't know that.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now