Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

785 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