+1 vote

I can send email , but how to save without send, and find it in draft folder?
thank for help...

    imap.ConnectSSL("imap.gmail.com", 993)  ' or ConnectSSL for SSL
    imap.UseBestLogin(str_user, str_str)


    For Each fi In imap.GetFolders()
        If (fi.Name.Contains("Draft")) Then

            ' Use builder class to create new email
            builder.To.Add(New Limilabs.Mail.Headers.MailBox(str_to))
            builder.Cc.Add(New Limilabs.Mail.Headers.MailBox(str_cc))

            builder.Subject = str_subject
            builder.Text = str_text

            builder.Importance = Limilabs.Mail.Headers.MimeImportance.Normal

            Dim email As Limilabs.Mail.IMail = builder.Create()

            '----------- how to do?
         End If
    Next
by
edited by

1 Answer

0 votes
 
Best answer

You need to upload created email to 'Draft' folder:

imap.ConnectSSL("imap.gmail.com")
imap.UseBestLogin(user, password)

Dim folders As New CommonFolders(imap.GetFolders())
imap.Select(folders.Draft)

Dim email As Limilabs.Mail.IMail = builder.Create() 
imap.UploadMessage(email)

imap.Close();

Some other points:

  • Use CommonFolders class instead of string.Contains to find common folders, as folder names may be localized.

  • MailBuilder.Html property is of type string, not bool. It contains Html version of your email.

by (297k points)
I've the same problem.
I' not yet connected to a mail program nor a (web) mailserver
We want to store/save the save the object as part of a database and send the mail on a given time.
for example save/read to/from file


Dim emailObj As Limilabs.Mail.IMail = builder.Create()
You can save email to disk using IMail.Save method or use IMail.Render(AddressHeaderRenderMode.Full) method. You can load IMail from byte array using MailBuilder.CreateFromEml method.
Thanks! (also for the quick response!)
...