VadaDosaIdly wrote: ↑
Everyone is giving half information and it is not helping anyways. I know it is the problem.
I am requesting if someone can explain steps to send email using API or other method so it would generate eml file and add a record into database.
Try interrogating your message table for message with uid=0 and delete the records. Then run dds if required. (Backup first).
Look at the documentation for the API. But I think using rules is the simplest way.
You also might want to search the forum for examples. I'm sure you're not the first person ever to have this need.
Instead of messing with the database, use a rule to copy the message to the user's sent box. I'm not 100% sure how you would set up the rule. Ideally it would be if from contains <@yourdomain.com> AND IP = 127.0.0.1 then copy message to imap folder Sent. I'm not sure about the IP part and I'm on my phone so I can't look for the best option. But you get the idea. It could be some other criteria like mua header or something else unique about your webmail.
Jimi's right. There's not much we can do. First, you have to stop the bleeding: Stop inserting gibberish into the database and delete the broken entries. Next, if you have eml files, you can run the data directory synchronizer to add those messages to the database. They will appear in the inbox, so then you will have to manually find them and move them to the sent folder if that's what you want.
Lastly, there are many MANY tutorials here for the API, plus there is the documentation. There is a very clear example in the documentation as well on how to send a message using the COM API (it won't help you put a copy in the sent folder, which is your real underlying issue).
However, as I said earlier, this can probably be achieved more easily by creating a rule that copies the message into the sent folder. You can bypass the API altogether.
Search, try one method, then come back with SPECIFIC questions and we can help. Nobody is going to just do it for you. Anyway, you haven't even shared any details about your setup, so how could we help even if we wanted to?