Solved

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

Posted on 2007-04-03
5
811 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

707 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

14 Experts available now in Live!

Get 1:1 Help Now