Sign in to follow this  
Followers 0
Symphatico

Problems with _INetMail sending RichText Format

5 posts in this topic

#1 ·  Posted (edited)

Hello all,

Newbie question: This is my first post here. I used the search option extensively, but without success.

I'm wrinting an application which should forward a result and open a new Outlook E-mail.

Now I'm running into a bit of a problem.

The result which I would like to send is a file path like file:\\server\share\subfolder. When I'm creating this e-mail with the _INetMail UDF, the mail gets created with the IE mailto option,

which is using the Outlook default mail format. (i.e. HTML). But when the e-mail opens in the HTML format the link gets broken by any special caracter like Ä,Ö,Ü.

That doesn't occur when it gets created in RichText format. So I have to find a way to create an E-Mail with the RichText format.

This is the mail part of my script I have so far.

Func Button7Click()
    Opt('RunErrorsFatal', 0)
    $address = ""
    $subject = "Created with Pathfinder"
;$Body = GuiCtrlRead($Input2)
    
    $body=  @CRLF & @CRLF & _
                "Created with Pathfinder" & @CRLF & _
                @CRLF & _
                GuiCtrlRead($Input2);& @CRLF & _
                            
_INetMail($address, $subject, $Body)
EndFunc

My questions:

1) Is there any way to send an E-mail with the _INetMail UDF with some unknown switch in RichText format?

I also don't want to use _INetSmtpMail because my task is just to open an E-mail and to put a body information into it.

2) Can I solve it by sending it directly through Outlook?

Therefore I found this snippet of Visual Basic Code and honestly speaking I'm not able to transfer it into AutoIt code.

May I ask you guys for help, please?

Private Sub CreateMailItem()
    Dim mailItem As Outlook.MailItem = _
        Me.CreateItem(Outlook.OlItemType.olMailItem)
    mailItem.Subject = "This is the subject"
    mailItem.To = "someone@example.com"
    mailItem.Body = "This is the message."
    mailItem.Form =  Outlook.OlFormat.olFormatRichText
    mailItem.Importance = Outlook.OlImportance.olImportanceLow
    mailItem.Display(False)
End Sub

Thank you for your most appreciated help

/Chris

Edited by Symphatico

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi all,

I'm still struggling around with transfering the VBCode > AutoIt

This is what I've got so far. :)

Func CreateMailItem()
    Dim $mailItem $As $Outlook.$mailItem = _
        $Me.CreateItem($Outlook.OlItemType.olMailItem)
    $mailItem.Subject = "This is the subject"
    $mailItem.To = "someone@example.com"
    $mailItem.Body = "This is the message."
    $mailItem.Form =  $Outlook.OlFormat.olFormatRichText
    $mailItem.Importance = $Outlook.OlImportance.olImportanceLow
    $mailItem.Display(0)
EndFunc

Looks nice, but it doesn't open a new Outlook message as it should. :) Where am I still wrong here?

Dear Experts - Could anybody give me a hand, please? Thank you.

Edited by Symphatico

Share this post


Link to post
Share on other sites

This script will send an Outlook email but will ask for a confirmation:

CreateMailItem()
Func CreateMailItem()
    Local $olMailItem    = 0
    Local $olFormatRichText = 3
    Local $olImportanceLow   = 0
    Local $olImportanceNormal= 1
    Local $olImportanceHigh  = 2

    $oOApp = ObjCreate("Outlook.Application")
    $oOMail = $oOApp.CreateItem($olMailItem)

    With $oOMail
        .To = ("to@domain.com")
        .Subject = "email subject"
        .BodyFormat =  $olFormatRichText
        .Importance = $olImportanceHigh
        .Body = "email message"
        .Display
        .Send
    EndWith
EndFunc

I vaguely remember that only outlookexpress has an option to suppress this warning thanks to the "i love you virus" that broke out on May 4 2000. (Still remember that one like it was yesterday :) )

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@JOS

Jos, you're my man!

I was searching for quite a time for this snippet of code and you managed to help me with that in the wink of an eye.

If I could, I would hug you for that! A BIG, BIG THANK YOU!

The send functionality I'll leave out for security reasons and to give the user the possibility to decide for himself.

BTW I remember the "I love you virus" like it was yesterday as well. It was a compleate mess thoses days.

So I highly appreciate Outlook's security function.

/Christian

Edited by Symphatico

Share this post


Link to post
Share on other sites

I wrote a small app to automate a task and at the end of the task I was supposed to prepare an email that the user could send. The problem that I had was: I used _InetMail to open a new message in Outlook and when I called it, it opened a new message and wrote what I wanted but it was not well formatted. Outlook reformatted it and increased the line spacing and that messed up my favorite format.

I searched the forum to find a clue and came here and got a clue to use COM obj because it has more options to set. One of them is the email format. I changed the email format to Rich Text instead of HTML and that solved my problem.

I am writing this here to help other people who have the same problem.

Thank you all for your efforts and time.

Ahmad

:)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0