login about faq

I can send an E-mail using smtp.gmail.com according to the example https://www.example-code.com/dataflex/smtp_gmailSsl.asp

Then I tried to save this mail in the sent folder of my own gmail account, with the code below, but that didn't work.

Get ComSelectMailbox of hoImap "Sent" to iSuccess returns False.

However, Get ComSelectMailbox of hoImap "Inbox" to iSuccess returns True and the mail can be saved in the inbox.

Shall it be so or do I make anything wrong? IMAP is activated on my gmail account.

Code

//Save the mail on the own gmail account

//  The mail has been sent.  Now save the email to the "Sent" folder
//  on your mail server.  (Your "Sent" folder could be named something else,
//  or you may store the email in any folder of your choosing.)
Get Create (RefClass(cComChilkatImap)) to hoImap
If (not(IsComObjectCreated(hoImap))) Begin
    Send CreateComObject of hoImap
End

//  Anything unlocks the component and begins a fully-functional 30-day trial.
Get ComUnlockComponent of hoMailman "XXXXXXXXXXXXXXXXXXXX" to iSuccess
If (iSuccess <> True) Begin
    Get ComLastErrorText of hoImap to sTemp1
    Showln sTemp1
    Procedure_Return
End

//  Connect to an IMAP server.
//  Use TLS
Set ComSsl of hoImap to True
Set ComPort of hoImap to 993
Get ComConnect of hoImap "imap.gmail.com" to iSuccess
If (iSuccess <> True) Begin
    Get ComLastErrorText of hoImap to sTemp1
    Showln sTemp1
    Procedure_Return
End

//  Login
Get ComLogin of hoImap "XXXXXX@gmail.com" "xyzabcde" to iSuccess
If (iSuccess <> True) Begin
    Get ComLastErrorText of hoImap to sTemp1
    Showln sTemp1
    Procedure_Return
End

//  Upload (save) the email to the "Sent" mailbox.
Get pvComObject of hoEmail to vEmail               
Get ComSelectMailbox of hoImap "Inbox" to iSuccess   //this work
//   Get ComSelectMailbox of hoImap "Sent" to iSuccess  //this doesn't work
If (iSuccess <> True) Begin
    Get ComLastErrorText of hoImap to sTemp1
    Showln sTemp1
    Procedure_Return
End

Get ComUidNext of hoImap to iUidNext

Get pvComObject of hoEmail to vEmail
Get ComAppendMail of hoImap "Inbox" vEmail to iSuccess
//   Get ComAppendMail of hoImap "Sent" vEmail to iSuccess
If (iSuccess <> True) Begin
    Get ComLastErrorText of hoImap to sTemp1
    Showln sTemp1
    Procedure_Return
End

Showln "Email saved to the Inbox folder."
//  Showln "Email saved to the Sent folder."

//  Disconnect from the IMAP server.
Get ComDisconnect of hoImap to iSuccess

asked Aug 22 '17 at 17:25

Bengt's gravatar image

Bengt
262


This was an unnessary question. Now I see that the Emails are automatically stored in the sent folder after they are sent so my code for storing them was not needed.

Sorry for this confusion.

Bengt

link

answered Aug 22 '17 at 18:14

Bengt's gravatar image

Bengt
262

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×30
×10
×8
×7

Asked: Aug 22 '17 at 17:25

Seen: 722 times

Last updated: Aug 22 '17 at 18:14

powered by OSQA