5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Use this forum if you want to discuss a problem or ask a question related to a hMailServer beta release.
Post Reply
Chris_G
New user
New user
Posts: 4
Joined: 2012-04-10 10:25

5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Chris_G » 2012-04-10 11:11

While using events i've discoverd the following issure:

hMS seems the have problems parsing the mail body
if the mail contains an inline embedded image
plus an additional attachment. If parsing fails oMessage.Body
and oMessage.HTMLBody contains nothing but an empty string.
oMessage.Subject is allways present.

If no additional attachment is present the body will be parsed
and everything is ok.

I've tested the following events "OnAcceptMessage" and "OnDeliverMessage"
using Event.Write oMessage.HTMLBody.

Is this a problem of my mail client or is hMS involved in this issure?
If this is not a hMS issure is there a way to work around this
issure? Using plain text mails or an other mail client isn't a pleasing option.

I've attached example mails the this post.
If the developers need more info just ask.

OS: Windows 2008 R2 64 Bit, (english) hMS installed in d:\hMailServer_5_4 using
internal MSSQL CE Database engine.

Greetings
Chris_G
Attachments
example mails.zip
contains working and failing example
(8.62 KiB) Downloaded 294 times

Bill48105
Developer
Developer
Posts: 6189
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Bill48105 » 2012-05-11 19:43

Thanks for info Chris_G.
Does this happen with other senders? I notice from headers:
X-Mailer: David.fx by Tobit.Software, Germany (0305.454A474448464C4F4C4C), Mime Converter 101.20

Want to make sure issue isn't sending client. At 1st glance they look ok but mime is a bitch

Btw seeing example script where you see issue would be helpful to reproduce here & confirm issue isn't in the script code itself.
Thx
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

Chris_G
New user
New user
Posts: 4
Joined: 2012-04-10 10:25

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Chris_G » 2012-05-22 15:02

Thanks for responding Bill and sorry for the delay.
I was quite busy.

I did the same tests with Outlook 2010 German and could reproduce the results. I'm quite shure that
my code is ok. In my setup it needs nothing more then

Sub OnAcceptMessage(oMessage)
EventLog.Write "This is the HTML part # " & oMessage.HTMLBody
End Sub

to get this "This is the HTML part # " output to the hMS eventlog. No HTML code at all if the attachment is present. Removing the attachment floods the log with the html body ;)

Meanwhile i wrote a work around parsing the mails for myself with regEx. This works great but i want to modify the HTML part of the mail delete something and save it afterwards before the mail gets delivered.

Please look into this thanks

Chris_G

Bill48105
Developer
Developer
Posts: 6189
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Bill48105 » 2012-05-22 15:47

Chris_G,
Does it do it just for Event.Write or you were just giving that as an example? What does oMessage.HTMLBody contain at that point? Are you sure it isn't something in particular about that email?
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

Chris_G
New user
New user
Posts: 4
Joined: 2012-04-10 10:25

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Chris_G » 2012-05-22 16:11

EventLog.Write is just an example. This code also enters
the else tree.

if Len(oMessage.HTMLBody) > 0 then
strMailBody = oMessage.HTMLBody
else
'my parsing code goes here.
End If

As i said before if an inline image is present in the mail
and a PDF attachment is also present, oMessage.HTMLBody contains
an empty string.

The image is copied with CTRL+V into the new composed mail,
after that a pdf file is attached and the mail is send.
Tested with Tobit Software and Outlook.

Chris_G

Chris_G
New user
New user
Posts: 4
Joined: 2012-04-10 10:25

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Chris_G » 2012-05-23 10:13

Can't edit my post above.
Just tested with Outlook if oMessage.HTMLBody is empty oMessage.Body is also empty.

Chris_G

niceshoes
New user
New user
Posts: 1
Joined: 2013-04-10 01:42

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by niceshoes » 2013-04-10 01:48

I'm actually using 5.3.3-B1879 version.
I am having the same issue. (oMessage.HTMLBody is empty)

I can capture oMessage.Body if the email is sent as plain text but oMessage.HTMLBody is empty if a HTML message is sent with a PDF attachment.

Is there any way to capture the message body?

Thanks...

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-09 12:24

This Problem seems to be current until now.

I have the Problem with hMS 5.4.2-B1964. Are there any known workarounds?
There's no problem with sending either ONLY an inline image or ONLY an attachment.

Information for this case:
- Forwarding message with inline image AND jpeg-attachment from Outlook2003.
- Generating new messages using script line: newMessage.HTMLBody = oMessage.HTMLBody
- The newMessage.HTMLBody is empty.

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-09 13:41

I would look at how you are sending your mail originally. For example, forwarding may be specifying sending original mail as an attachment and/or your email client/script is screwing up multipart message format.

hMail just takes whats its given and processes it. If the mail is already malformed then the old adage of GIGO applies.

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-10 23:06

I think the problem is your script but could be your email client.

I have looked at the mails you pm'ed to me and yes the receieved mail has an empty html body.

BUT how was that mail generated ? Did you edit it in your script?

using my mail client (eudora or live mail), if I place an inline image in my mail it puts something like following in my htmlbody

Code: Select all

<img src="cid:6.2.5.6.2.20140910213141.003b8f70@wheresmymailserver.com.0" width=440 height=626 alt="Emacs!">
That is a reference to an additional part of the multipart mail which is placed below the closing html body tag. i.e. outside of the html portion of the mail in its own"part" as an attachment.

hMail treats it internally as an attachment and image file is in the attachments collection.

If you are going to try and construct multipart mails via script using the com api you better be sure you know how to format your mail correctly and generate the correct multipart boundaries of your mail.

Its not obvious BUT you can add these in your htmlbody after the closing body tag ( I think ) and your email client should see as them as what they are. But they better be correct.

So the question is, as your script receives the mail and before you start trying to change anything in it, what does oMessage.body contain and what does oMessage.HTMLBody contain ? And what does your oMessage.Attachments collection contain ?

The htmlbody should contain the reference to your inline image. My email clients add it OK. Does yours ?

There does not seem to be anything in the com api for directly referencing "parts" of a "multipart" mail. But that may be because hmail internally just treats everything after headers as body, htmlbody and attachments. I'm not too sure about that. You would need to ask Martin whether these "part" references should be added to COM API.
But that doesn't explain why your htmlbody is empty unless its your email client or your script or possibly even hmail. I don't know so please do the checks for body content as aked above and that should help identify where the problem is occuring.

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-10 23:46

AND

if you are creating a new message using script and com api, its up to you as programmer to add all the right multipart boundaries if thats what you want and NOT assume that they are auto duplicated from the original message cos they ain't.

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-16 10:53

I can not see why I have to learn how to build a multipart message when I only want to forward it.
Why isn't it possible just to copy a message by a script and then change some headers? That's all I want!

I think of a function like:

Code: Select all

Set newMessage = oMessage
This code example fails because newMessage will overwrite oMessage due to the same filename.
If it was possible to get a different filename, then all different mime types could be used without analyzing and rebuilding them.

What do you think about it?

User avatar
mattg
Moderator
Moderator
Posts: 19810
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by mattg » 2014-09-16 11:35

Esd wrote:I can not see why I have to learn how to build a multipart message when I only want to forward it.
Why isn't it possible just to copy a message by a script and then change some headers? That's all I want!
Sorry, which of those two different things do you want to do?

DO you want to forward the message, or do you want to copy it and then change a few things?
Esd wrote:I think of a function like:

Code: Select all

Set newMessage = oMessage
This code example fails because newMessage will overwrite oMessage due to the same filename.
Are you sure?
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-16 12:29

Hi mattg,

in my special environment I need to copy the message first, change some headers and then send it.
It's like forwarding, but with more changes than rules allow.

I have to send an extra message for each recipient with modified From, To and Cc headers, dependent on whether the recipient is local or external. I wrote a script for that and it's working great, but there's still this problem with multipart messages.

For answering your question:
Yes I'm sure. I want to copy the message and then change something.

Is it possible?

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-16 14:13

You call it message copy but strictly speaking that isn't what you are doing or least that isn't how you have to do it in COM API
In hmail forwarding is a copy, generating a new mail in COM API isn't, it's a new mail with parts copied from another mail.

Please try following:

when you create your new mail with

Code: Select all

newMessage.body = oMessage.Body
newMessage.htmlbody = oMessage.htmlBody
always copy both regardless of size or if empty.

Then also you MUST generate all attachments for newMessage which exist in oMessage. This is tricky because you are likely to need to get each attachment from oMessage, write it to disk and then attach it to newMessage. You must do that or you WILL lose content. Thats just how it works.

On the other hand, if you just forward a copy of the incoming mails to another mail box and then do your modifications on forwarded mail headers only, then you won't need to mess with body or attachments or multiparts because the forward has already taken care of that for you.

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-16 14:56

Thanks for your answer, I made those changes and will see what happens.
Attachment handling is already included in my script and works fine.

Is there a reason why forwarding by hMailServer is possible but not by using COM API? It would make things much easier...

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-16 14:57

don't know, I didn't write it and I'm not a C++ programmer/developer.

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-16 15:25

With copying both body-types to the newMessage there's still the problem according to the thread topic.

Is there a developer who can help with this problem?

User avatar
mattg
Moderator
Moderator
Posts: 19810
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by mattg » 2014-09-16 15:34

can you please show your script, and can you show the message (.eml file) before your script, and the new message after your script
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-16 15:47

+1 show your script and before and after eml files.

I think that the COM API deconstructs the incoming email into COM API variables. You can simply change any variable in Message but if you create a new message object then COM API constructs a completely new mail which probably won't have same multipart structure as incoming message, especially if that mail has complex multipart structure.

Again, use a rule to forward mail to another mialbox and then do your changes to headers on it there.

Matt,
VBScript doesn't allow you to copy an object. Infact nMessage = oMessage wouldn't work anyway because oMessage is actually a pointer to the Message object and not the actual object itself. i.e. createObject creates an object and puts pointer to the object in the target variable.

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-16 18:00

Note:

Using forward in rules actually sends a "COPY" to the recipeint you have specified in the forward AND delivers the original mail to the original recipient.

If you have option in hmail to add "Delivered-To" header then it should be easy as the forwarded email arrives to trap it with another rule and do your processing (which can include removing the first delivered-to header if you want).

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-16 22:39

I fear it's not so easy. I think I can't use forward in rules because that is not exactly what I want.
I'll try to explain:

This is the situation:
  • At ISP there's only one central e-mail-address (info@mycompany.tld) for receiving messages from the internet. No chance to get more. Only one, that's given.
  • There are multiple user accounts in hMS which can't receive messages from the internet directly.
  • hMS fetches the messages from ISP via POP3 and stores them into a central local mailbox.
  • Some superusers forward the ingoing messages to the local user accounts by using e-mail clients like Outlook. (It's only a little amount of messages, so there's not much for them to do.)
  • The respective user can send messages to other local accounts AND/OR to external recipients in the internet.
This is my intention:
  • The Return-Path for outgoing mail must be set to the only inbox address (info@mycompany.tld).
  • For outgoing messages the From-Address must be set to the central internet address in this format: "Firstname Lastname <info@mycompany.tld>" in order to be able to send an answer to a routable address.
  • Recipients in the internet shouldn't see the local addresses in the To or Cc line. They should see who got the message too, but not local addresses. For local users they should see the central internet address in this format: "Firstname Lastname <info@mycompany.tld>". Additional external addresses must leave unchanged.
  • The same message to local users must be left untouched. (No change to Return-Path, To or Cc.)
This is my approach:
  • Message is delivered by an e-mail client like Outlook. The To and Cc line may contain mixed addresses, local and/or external, and also there can be mixed Bcc recipients.
  • Store attachments temporarily to local disk.
  • Generate one separate message (newMessage or even nMessage) for each recipient that is included in oMessage.Recipients. (This is what I called forwarding, maybe that was misleading.)
  • For external recipients change headers Return-Path, From, To and Cc.
  • For local (internal) recipients leave the headers as they are.
  • Add Subject, Body, HTMLBody. (THIS is the point where multipart messages fail, but only if there's an inline image AND an additional attachment.)
  • Add all attachments.
  • Save and send each message.
  • Delete the attachments from disk.
  • Catch oMessage by a rule and delete it.
So far, everything works fine except the multipart thing.

Tomorrow I'll post my complete script if you want, and I will generate some test messages.

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-16 23:00

yes your script and the sent eml file and the received eml file are a must. And also if you can stop your script before it runs the eml file received by hmail before your script runs because that will be the most critical to see its structure.

And in eventhandlers.vbs adding following to OnAcceptMessage

Code: Select all

Sub OnAcceptMessage
 ViewStuff oMessage
End Sub
and add this to bottom of eventhandlers.vbs

Code: Select all

Sub ViewStuff(oMessage)
 EventLog.Write ("ViewStuff" )
 EventLog.Write ("From: " & oMessage.From )
 EventLog.Write ("FromAddress: " & oMessage.FromAddress )
 Dim oHeader
 For oHeader = 0 to oMessage.Headers.Count-1
  EventLog.Write (oMessage.Headers(oHeader).Name & ": " & oMessage.Headers(oHeader).Value)
 Next
 EventLog.Write ("oMessage.Size: " & oMessage.Size )
 EventLog.Write ("oMessage.Date: " & oMessage.Date )

 EventLog.Write ("Recipients.Count " & oMessage.Recipients.Count)
 Dim oRecipient
 For oRecipient = 0 to oMessage.Recipients.Count-1
  EventLog.Write ("Recipients " & oRecipient & " : " & oMessage.Recipients(oRecipient).Address _
  & " : " & oMessage.Recipients(oRecipient).IsLocalUser _
  & " : " & oMessage.Recipients(oRecipient).OriginalAddress )
  Next
 EventLog.Write (" ")
 EventLog.Write ("oMessage.Body: " & VBCrLf & oMessage.Body )
 EventLog.Write (" ")
 EventLog.Write ("oMessage.HTMLBody: " & VBCrLf & oMessage.HTMLBody )
 EventLog.Write (" ")
 
 Dim oAttachment
 For oAttachment = 0 to oMessage.Attachments.Count-1
  EventLog.Write ("oMessage.Attachments(oAttachment).Filename: " & oMessage.Attachments(oAttachment).Filename )
  Next

 EventLog.Write (" ")  
 
End Sub
The problem you are going to have is that if what you are saying is correct then it would be happening to a lot of people which it isn't. Only a couple of people using earlier version of hmail than yours. You are the only one using 5.4 reporting this.

Also 5.5 is now live and that has had a lot of changes made with numerous little fixes, so you should really be testing this problem out with that version now. i.e. upgrade to 5.5 first, and then see if problem persists. If it does then it will make it easier to find using current code base.

User avatar
mattg
Moderator
Moderator
Posts: 19810
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by mattg » 2014-09-17 05:05

Esd wrote:This is the situation:
  • At ISP there's only one central e-mail-address (info@mycompany.tld) for receiving messages from the internet. No chance to get more. Only one, that's given.
I and expect that is the problem.

Host your own mail, and remove the ISP from the equation - that'd be easier.

Also, I'd look at coding without using the hMailserver COM API if you MUST continue down this path.
I'd look at using the language of your choice, and hooking to hMailserver with IMAP connectors, modifying the message, and returning it to hMailserver.

I guess my point is that if the hMailserver COM API doesn't meet your needs, there are alternatives that will achieve the same outcome.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-17 14:38

I updated to hMS 5.5-B2074.

The HTMLBody is still empty.

How can I stop a script so that I can grab the eml-file before script processing?

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-17 15:04

I did a test late last night and have reproduced what you are experiencing.
My test confirms that the eml file recieved by hmail is correct but that in com api body and htmlbody are empty.

As you say, this only happens when you put an inline image in the mail.

Further I did a test where I modified a header and saved the mail. The mail continued and was delivered intact.

So whilst com api is not showing the body and htmlbody, it is infact still in the message object or at least still in the mail being processed. So hmail is processing mails correctly. The only question is whether com api should extend to the full functionality of an email client interface for editing mails. I don't know the answer to that but I suspect not. Depends on what the original design idea was which I have no clue about.
I have emailed Martin about this and await a resposne.

In the mean time I would again point out to you that I have provided you with a workable solution which will allow you to do what you want. i.e. generate a full copy email and modify headers without losing anything.
Also you can modify the headers in original mail and save without generating a new mail and it will work.
i.e. modify original mails headers and save (if you want). Use a forward to take a "copy" if you want. And you can just forward to each user and run a rule to run a script to modify headers in each of those users accounts before they see the mail (if you want).
If that is not good enough, then as matt suggests, you can use some other programming interface to achieve your goals.

I doubt any changes will be made to 5.5 (if at all) until at least next release and there is no telling when that will be.

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-09-17 15:50

Esd wrote:I updated to hMS 5.5-B2074.

The HTMLBody is still empty.

How can I stop a script so that I can grab the eml-file before script processing?

Code: Select all

   Sub OnAcceptMessage(oClient, oMessage)
      With CreateObject("Scripting.FileSystemObject")
         .CopyFile oMessage.FileName, "C:\hMailServer\MyTemp\", True
      End With
   End Sub
Should be somewhere between SPAM check and AV check and before Rules.
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-17 16:01

Esd wrote:I updated to hMS 5.5-B2074.
How can I stop a script so that I can grab the eml-file before script processing?
You put your code in its own sub for example

Sub MyCode(oMessage)

.... your code goes here

End Sub

then you call that sub from onAcceptMessage with line

MyCode oMessage

then in future to stop MyCode from running all you need to do is comment out the call in onAcceptMessage.

OR

create sub as above and invoke it from a a rule with run function. Then you can just enable or disable the rule to switch it on or off.

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-17 16:37

@Søren R.
@percepts
Thank you!

I did it similar to Sørens suggestion, but much more complicated, so I appreciate your code example.

Is it possible to rename that copied message and give it back to the script for further processing? I think that could solve the problem.

(Let me guess: the answer is no...) :cry:

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-17 16:50

in com api look at the functions available to you in "utilities".

never tried them so can't help with them

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-09-17 16:58

Esd wrote:@Søren R.
@percepts
Thank you!

I did it similar to Sørens suggestion, but much more complicated, so I appreciate your code example.

Is it possible to rename that copied message and give it back to the script for further processing? I think that could solve the problem.

(Let me guess: the answer is no...) :cry:
Hmm.... For delivery to local accounts you could perhaps look at this for inspiration...

Code: Select all

Dim obApp
Set obApp = CreateObject("hMailServer.Application")
Call obApp.Authenticate("Administrator", "test")
Set obAccount = obApp.Domains(0).Accounts(0)
Call obApp.Utilities.ImportMessageFromFileToIMAPFolder("C:\hMailServer\Data\test.com\test\Test.eml", obAccount.ID, "Inbox.Spam")
I must admit I am still not 100% clear on what you are trying to achieve.. :oops:
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-09-17 17:44

Just noticed this in the hMailServer COM API documents under Utilities...

Code: Select all

ImportMessageFromFile(string sFilename, long iAccountID)

Imports a message from a file on disk for delivery or to a specific account.
I think this calls for a bit of experimenting :mrgreen:
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-17 17:58

Yes, I found this post by martin, but I don't understand how to handle the imported message for script processing at the moment... :?
viewtopic.php?f=7&t=10003&p=53858&hilit ... ile#p53858

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-09-17 19:51

OK, got it...

Code: Select all

      With CreateObject("hMailServer.Application")
         .Authenticate "Administrator", "Secret"
         .Utilities.ImportMessageFromFile "C:\hMailServer\Data\test.eml", 0
      End With
- or -

Code: Select all

      Dim oApp
      Set oApp = CreateObject("hMailServer.Application")
      Call oApp.Authenticate("Administrator", "Secret")
      Call oApp.Utilities.ImportMessageFromFile("C:\hMailServer\Data\test.eml", 0)
However, there are a couple of BUT's...

1: "Message-ID:" MUST NOT exist in the database already - Important!
2: File must reside i Data directory, hMailServer will remove the file once processed.

Had to poke through the source code to figure it all out 8)

Regarding the "Message-ID:", if the original message is already received by hMailServer (it would be for us to save the email) then it is important to change it. It is a unique identifier and the following change is perfectly legal (I think... http://en.wikipedia.org/wiki/Message-ID):

Original:
Message-ID: <0.0.E.5D0.1CF780FCB00C804.0@mta-218.globasemail.com>

Modified:
Message-ID: <419.0.0.E.5D0.1CF780FCB00C804.0@mta-218.globasemail.com>

Other than that it is "only" a matter of VBScripting the modifications into the file before re-importing into hMailServer.

My test was simply sending a mail from A to B, save the email halfway, change the Message-ID and re-import it... B would then receive two identical copies (except for Message-ID).
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-17 20:01

Great! Thanks for your efforts!
I will do some testing tomorrow.

Is the 419 just a number or has it a special meaning?
Is it okay to add the same number every time or must it be a random number?

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-09-17 20:11

Esd wrote:Great! Thanks for your efforts!
I will do some testing tomorrow.

Is the 419 just a number or has it a special meaning?
Is it okay to add the same number every time or must it be a random number?
The link to WiKi will give you some pointers to how to calculate a new Message-ID...

419... No special meaning allthough I can see now that it can be misunderstood :mrgreen:
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by percepts » 2014-09-17 20:21

percepts wrote:in com api look at the functions available to you in "utilities".

never tried them so can't help with them

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-18 16:40

I did some coding today and this is my result so far:
  • the original message is copied to the Temp folder, changed to a new Message-ID and moved back to the Data folder.
  • the message will then be imported to the database and sent as a duplicate to the original recipient(s).
This is just an experiment!
I will see how I can use this for further scripting.

Code: Select all

Sub Testfunction(oMessage)
	
	'Check for X-hMS-Flag, set in this script for preventing message from being processed again.
	If oMessage.HeaderValue("X-hMS-Flag") = "1" Then
		Set oMessage = Nothing
		EventLog.Write("X-hMS-Flag = 1, message will not be processed.")

	Else 
		dim oPathFilename, oFilename
		dim nPathFilename, nFilename, nPathFilenameTemp, nPathFilenameData
		dim FilenameArray
		dim PathData, PathTemp
		dim fso, msgFile, objFile, nMessage, theApp   'objects
		dim FileToEdit
		dim strText, strNewText
		dim SearchString, ReplaceString
		
		'Username & password for authentication:
		Const myUser = "Administrator"
		Const myPass = "Adminpassword"
		'Other constants:
		Const ForFileReading = 1
		Const ForFileWriting = 2

		PathData = ("C:\Program Files (x86)\hMailServer\Data\")
		PathTemp = ("C:\Program Files (x86)\hMailServer\Temp\")
		
		'Create File System Object:
		Set fso = CreateObject("Scripting.FileSystemObject")

		'Logging:
		EventLog.Write("-------Test function-----------")
		EventLog.Write("          Subject: " & oMessage.Subject)
		
		'Getting the original file name of the message:
		oPathFilename = oMessage.Filename
		FilenameArray = Split(oPathFilename,"\")
		oFilename = FilenameArray(4)
		
		'Getting a new GUID:
		'(Maybe there's a better way, but I don't know...)
		Set nMessage = CreateObject("hMailServer.Message")
		nPathFilename = nMessage.Filename
		FilenameArray = Split(nPathFilename,"\")
		nFilename = FilenameArray(4)
		nPathFilenameTemp = PathTemp & nFilename
		Set nMessage = Nothing
		
		'Some more logging:
		EventLog.Write("        oFilename: " & oFilename)
		EventLog.Write("      Source path: " & oPathFilename)
		EventLog.Write(" Destination path: " & nPathFilenameTemp)
		
		'Copy message to Temp directory:
		Set msgFile = fso.GetFile(oPathFilename)
		msgFile.Copy(nPathFilenameTemp)
		
		'Some logging again:
		EventLog.Write("Message " & oFilename & " copied to "  & nPathFilenameTemp & ".")
		
		oMessage.Save    '(is this necessary?)
		
		'Define the Search string:
		SearchString = "Message-ID: <"
		
		'Define the Replace string:
		'	(Setting the X-hMS-Flag for preventing message from being processed again.)
		'	(Setting a number [for example: 1] and a dot in front of the message id.)
		ReplaceString = "X-hMS-Flag: 1" & vbNewLine & "Message-ID: <1."

		'Open the message file for reading:
		Set objFile = fso.OpenTextFile(nPathFilenameTemp, ForFileReading)
		
		'Read message file content to string:
		strText = objFile.ReadAll
		
		'Close message file. 
		'Later it must be opened again, but for writing.
		objFile.Close

		If IsEmpty(strText) Then
			EventLog.Write(nPathFilenameTemp & ": strText is empty!")
		Else
			'The text replacement:
			strNewText = Replace(cStr(strText), SearchString, ReplaceString, 1, -1, 1)
			
			'Open the message file again for writing:
			Set objFile = fso.OpenTextFile(nPathFilenameTemp, ForFileWriting)
			
			'Write changed string to message file:
			objFile.WriteLine strNewText
			
			'Close changed message file:
			objFile.Close
			
			'Some logging for feeling almost like a hero:
			EventLog.Write("Replacement done.")
		End If
		
		
		'Move processed message back to Data folder.
		nPathFilenameData = PathData & nFilename
		Set msgFile = fso.GetFile(nPathFilenameTemp)
		msgFile.Move(nPathFilenameData)
		EventLog.Write("Message " & nFilename & " has been moved to Data folder.") 
				
		'Creating application:
		Set theApp = CreateObject("hMailServer.Application")
		Call theApp.Authenticate(myUser, myPass)
		
		'Import the processed message to database:
		EventLog.Write(" Try to import: " & nPathFilenameData)
		Call theApp.Utilities.ImportMessageFromFile(nPathFilenameData,0)
		
		'Delete objects:
		Set fso = Nothing
		Set objFile = Nothing
		Set msgFile = Nothing
		
	End If
	
End Sub


:D

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-09-18 20:51

Sorry, could not help it :oops:
Had to make a few changes...

Code: Select all

   Function CreateGUID()
      Dim TypeLib
      Set TypeLib = CreateObject("Scriptlet.TypeLib")
      CreateGUID = Left(TypeLib.Guid, 38)
   End Function
   
   Sub Testfunction(oMessage)

      dim oPathFilename, oFilename, oFile
      dim nPathFilename, nFilename, nPathFilenameTemp, nPathFilenameData
      dim strText, strNewText
      dim SearchString, ReplaceString

      ' Username & password for authentication:
      Const Admin = "Administrator"
      Const Password = "Adminpassword"
      ' Other constants:
      Const ForFileReading = 1
      Const ForFileWriting = 2
      Const PathData = ("C:\Program Files (x86)\hMailServer\Data\")
      Const PathTemp = ("C:\Program Files (x86)\hMailServer\Temp\")

      ' Check for X-hMS-Flag, set in this script for preventing message from being processed again.
      If oMessage.HeaderValue("X-hMS-Flag") = "1" Then
         EventLog.Write("X-hMS-Flag = 1, message will not be processed.")

      Else
         ' Logging:
         EventLog.Write("-------Test function-----------")
         EventLog.Write("          Subject: " & oMessage.Subject)

         ' Getting the original file name of the message:
         With CreateObject("Scripting.FileSystemObject")
            oPathFilename = .GetAbsolutePathName(oMessage.Filename)
            oFilename = .GetFileName(oPathFilename)

            ' Getting a new GUID:
            nFilename = CreateGUID & ".eml"
            nPathFilenameTemp = PathTemp & nFilename

            ' Some more logging:
            EventLog.Write("        oFilename: " & oFilename)
            EventLog.Write("      Source path: " & oPathFilename)
            EventLog.Write(" Destination path: " & nPathFilenameTemp)

            ' Copy message to Temp directory: ( False means no overwrite )
            .CopyFile oPathFilename, nPathFilenameTemp, False

            ' Some logging again:
            EventLog.Write("Message " & oFilename & " copied to "  & nPathFilenameTemp & ".")

            ' Define the Search string:
            SearchString = "Message-ID: <"

            ' Define the Replace string:
            '   (Setting the X-hMS-Flag for preventing message from being processed again.)
            '   (Setting a number [for example: 1] and a dot in front of the message id.)
            ReplaceString = "X-hMS-Flag: 1" & vbNewLine & "Message-ID: <1."

            ' Open the message file for reading:
            Set oFile = .OpenTextFile(nPathFilenameTemp, ForFileReading)
            strText = oFile.ReadAll
            oFile.Close

            If IsEmpty(strText) Then
               EventLog.Write(nPathFilenameTemp & ": strText is empty!")
            Else
               ' The text replacement:
               strNewText = Replace(cStr(strText), SearchString, ReplaceString, 1, -1, 1)

               ' Open the message file again for writing:
               Set oFile = .OpenTextFile(nPathFilenameTemp, ForFileWriting)
               oFile.WriteLine strNewText
               oFile.Close

               ' Some logging for feeling almost like a hero:
               EventLog.Write("Replacement done.")
            End If

            ' Move processed message back to Data folder.
            .MoveFile nPathFilenameTemp, PathData
         End With

         EventLog.Write("Message " & nFilename & " has been moved to Data folder.")

         ' Creating application:
         With CreateObject("hMailServer.Application")
            .Authenticate Admin, Password

            ' Import the processed message to database:
            nPathFilenameData = PathData & nFilename
            EventLog.Write(" Try to import: " & nPathFilenameData)
            .Utilities.ImportMessageFromFile nPathFilenameData, 0
         End With
      End If
   End Sub

2496	"2014-09-18 20:37:07.684"	"-------Test function-----------"
2496	"2014-09-18 20:37:07.684"	"          Subject: test"
2496	"2014-09-18 20:37:07.684"	"        oFilename: {7CD2E0AF-2ADC-4A23-89D1-7B2F2C8C3001}.eml"
2496	"2014-09-18 20:37:07.684"	"      Source path: C:\hMailServer\Data\{7CD2E0AF-2ADC-4A23-89D1-7B2F2C8C3001}.eml"
2496	"2014-09-18 20:37:07.684"	" Destination path: C:\hMailServer\Temp\{783C591F-EE30-4900-A091-4DB09B7A992B}.eml"
2496	"2014-09-18 20:37:07.684"	"Message {7CD2E0AF-2ADC-4A23-89D1-7B2F2C8C3001}.eml copied to C:\hMailServer\Temp\{783C591F-EE30-4900-A091-4DB09B7A992B}.eml."
2496	"2014-09-18 20:37:07.684"	"Replacement done."
2496	"2014-09-18 20:37:07.684"	"Message {783C591F-EE30-4900-A091-4DB09B7A992B}.eml has been moved to Data folder."
2496	"2014-09-18 20:37:07.684"	" Try to import: C:\hMailServer\Data\{783C591F-EE30-4900-A091-4DB09B7A992B}.eml"
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-18 21:49

:shock: Whoa, I'm very impressed!
Now I have to find out how I can make changes to the copied messages....

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-09-18 21:57

Esd wrote::shock: Whoa, I'm very impressed!
Now I have to find out how I can make changes to the copied messages....
Kürzere Code wird schneller ausgeführt :mrgreen:
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-18 22:39

:lol:
Yes, that's true, but I am not a professional programmer. It's okay for me if it works. Nevertheless I appreciate any improvements!
Tak for den hjælp!

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-09-19 00:41

I think I may have found an easier way 8)

Code: Select all

   Sub WonderIfThisWorks(oMessage)

      Dim sFile, sMessageFilename, sNewMessageFilename, sMessageID

      With CreateObject("hMailServer.Message")
         sNewMessageFilename = .Filename
         sMessageId = oMessage.HeaderValue("Message-ID")
         sMessageFilename = oMessage.Filename

         With CreateObject("Scripting.FileSystemObject")
            .CopyFile sMessageFilename, sNewMessageFilename, True
         End With

         ' ChangeLog Version 4.4 - Build 255 (2007-01-12)
         ' API: The RefreshContent() method on the hMailServer.Message object
         ' allows you to reload the content of an email message from disk.
         .RefreshContent
         .From = "John Doe <info@mydomain.tld>"
         .FromAddress = "info@mydomain.tld"
         .AddRecipient "Soren Rathje", "soren@example.com"

         ' Need to change the Message-ID from the used one
         sMessageID = "<1." & Mid(sMessageID,2) & ">"
         .HeaderValue("Message-ID") = sMessageID

         ' Send email
         .Save
      End With
   End Sub

Message in "Sent Mail" folder

Code: Select all


MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
Date: Fri, 19 Sep 2014 00:14:44 +0200
From: SPAM Trap <spam@example.com>
To: soren@example.com
Subject: test4
Reply-To: spam@example.com
Mail-Reply-To: spam@example.com
Message-ID: <4c62f476bbb5b34574af1d743593887a@example.com>
X-Sender: spam@example.com
User-Agent: Roundcube Webmail/1.0.2

test4

Original message received in Inbox

Code: Select all


Return-Path: spam@example.com
Delivered-To: soren@example.com
Received: from www.example.com (mx2.example.com [192.168.0.50])
	by mx.example.com
	; Fri, 19 Sep 2014 00:13:35 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
Date: Fri, 19 Sep 2014 00:14:44 +0200
From: SPAM Trap <spam@example.com>
To: soren@example.com
Subject: test4
Reply-To: spam@example.com
Mail-Reply-To: spam@example.com
Message-ID: <4c62f476bbb5b34574af1d743593887a@example.com>
X-Sender: spam@example.com
User-Agent: Roundcube Webmail/1.0.2

test4

Cloned message received in Inbox

Code: Select all


Return-Path: info@mydomain.tld
Delivered-To: soren@example.com
Received: from www.example.com (mx2.example.com [192.168.0.50]) by mx.example.com ; Fri, 19
 Sep 2014 00:13:35 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII; format=flowed
Content-Transfer-Encoding: 7bit
Date: Fri, 19 Sep 2014 00:14:44 +0200
From: John Doe <info@mydomain.tld>
To: soren@example.com,"Soren Rathje" <soren@example.com>
Subject: test4
Reply-To: spam@example.com
Mail-Reply-To: spam@example.com
Message-ID: <1.4c62f476bbb5b34574af1d743593887a@example.com>>
X-Sender: spam@example.com
User-Agent: Roundcube Webmail/1.0.2

test4

Not sure what it can be used for, but now my brain can relax :mrgreen:
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-19 12:41

:D
Very nice work! That's exactly what I wanted to have!
Now the body content of the new message is exactly like in the original message, with body, htmlbody, attachments and all inline images. Very good!

How did you prevent the new message from being processed again?
During my first test I got lots of copies that I had to delete manually. Then I inserted my X-hMS-Flag and solved this problem, but how did you do?


A small correction:

Code: Select all

' Need to change the Message-ID from the used one
         sMessageID = "<1." & Mid(sMessageID,2)        '& ">"   <=== The closing bracket is not needed.

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-09-19 13:47

Esd wrote::D
Very nice work! That's exactly what I wanted to have!
Now the body content of the new message is exactly like in the original message, with body, htmlbody, attachments and all inline images. Very good!

How did you prevent the new message from being processed again?
During my first test I got lots of copies that I had to delete manually. Then I inserted my X-hMS-Flag and solved this problem, but how did you do?


A small correction:

Code: Select all

' Need to change the Message-ID from the used one
         sMessageID = "<1." & Mid(sMessageID,2)        '& ">"   <=== The closing bracket is not needed.
I fired it off with this... Since I change "From" in the code it won't happen again. If you don't change "From" you will have to add the "X-hMailServer-MyFlag" header thingy again.

Code: Select all

   Sub OnAcceptMessage(oClient, oMessage)
      If (InStr(oMessage.From, "spam@example.com") > 0) Then Call WonderIfThisWorks(oMessage)
   End Sub
Thanks, I missed that extra closing bracket but it seems to do no harm :wink:

Also... I found that the code needs "AddRecipient" in order to send the email. I just poked my email address in, I presume (but have not tried) something like ".AddRecipient = oMessage.Recipients" could reinstate the original recipients.
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

Esd
Normal user
Normal user
Posts: 32
Joined: 2014-08-06 17:39
Location: Hamburg

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by Esd » 2014-09-19 16:16

@SørenR:
I'm ready with integrating your great work into my script and it works very fine! In my case there's no Problem with .AddRecipient, because I first do .ClearRecipients() and then I add each recipient separately.

@all:
Many thanks to all of you helping guys in this forum!

dimansound
New user
New user
Posts: 16
Joined: 2012-09-23 10:55

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by dimansound » 2014-12-04 17:19

How to manually insert the raw message into the database?

User avatar
mattg
Moderator
Moderator
Posts: 19810
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by mattg » 2014-12-04 18:46

a) we don't support direct injection into the database - use the provided API
b) messages aren't stored in the database, just metadata about the messages. The message is stored in the file system
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

dimansound
New user
New user
Posts: 16
Joined: 2012-09-23 10:55

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by dimansound » 2014-12-04 18:53

how to link a message with any account? I tried through ImportMessageFromFile but it does not work, return false.
eml file messages received from other mail servers, and this message I need to point to hmailserver mailbox (eg the same as is the case fetch external mail)

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-12-04 20:37

dimansound wrote:how to link a message with any account? I tried through ImportMessageFromFile but it does not work, return false.
eml file messages received from other mail servers, and this message I need to point to hmailserver mailbox (eg the same as is the case fetch external mail)
It does work - if you know what to look for :wink:

Have you looked at;

ImportMessageFromFileToIMAPFolder(string sFilename, long iAccountID, string sIMAPFolder)

If you only want to store the message without processing it...
Dim obApp
Set obApp = CreateObject("hMailServer.Application")
Call obApp.Authenticate("Administrator", "secret")
Set obAccount = obApp.Domains(0).Accounts(0)
Call obApp.Utilities.ImportMessageFromFileToIMAPFolder("C:\test.eml", obAccount.ID, "INBOX")
The "0"s (specific domain and specific user) you need to find first..
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

dimansound
New user
New user
Posts: 16
Joined: 2012-09-23 10:55

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by dimansound » 2014-12-04 22:50

ImportMessageFromFileToIMAPFolder also returns false

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-12-05 02:13

dimansound wrote:ImportMessageFromFileToIMAPFolder also returns false
Please post code...
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

dimansound
New user
New user
Posts: 16
Joined: 2012-09-23 10:55

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by dimansound » 2014-12-05 08:37

Dim obApp
Set obApp = CreateObject("hMailServer.Application")
Call obApp.Authenticate("Administrator", "123456")
Set obDomain = obApp.Domains.ItemByName("ext.testmail.com")
Set obAccount = obDomain.Accounts.ItemByAddress("1@ext.testmail.com")
obApp.Utilities.ImportMessageFromFileToIMAPFolder("D:\1.eml", obAccount.ID, "INBOX")

User avatar
SorenR
Senior user
Senior user
Posts: 3140
Joined: 2006-08-21 15:38
Location: Denmark

Re: 5.4 Build 2011120101 Scripting oMessage.(HTML)Body empty

Post by SorenR » 2014-12-05 17:44

dimansound wrote:Dim obApp
Set obApp = CreateObject("hMailServer.Application")
Call obApp.Authenticate("Administrator", "123456")
Set obDomain = obApp.Domains.ItemByName("ext.testmail.com")
Set obAccount = obDomain.Accounts.ItemByAddress("1@ext.testmail.com")
obApp.Utilities.ImportMessageFromFileToIMAPFolder("D:\1.eml", obAccount.ID, "INBOX")
Try importing the messagefile from your hMailServer DATA directory... Also, the message cannot exist already - as a minimum try change the header "Message-ID" by appending e.g. a "1-" to it...
It seems to have made the difference further back in the thread...

I still need to completely dissect the source code but these are the immediate observations..
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

Post Reply