Free Support Forum - aspose.com

Emails Sent by Loading Oft Files not rendering Custom Fields

We are using a Custom Outlook Form are loading the custom oft and updating the recipients and body and sending the email using SMTPClient.

Below are key code lines :
MapiMessage mapiMsg = MapiMessage.fromFile(oftFileName);

MailConversionOptions options = new MailConversionOptions();
options.setConvertAsTnef(true);

client.setUseTnef(true);

When the email is received by a user the Custom Field Initial value loads properly. However once the email is marked as read the custom field values stop loading.

Please note the Custom field values work fine when the email is sent manually from outlook using the oft

Please see attached oft and fdm files to see how custom labels are being loaded from the body.

@chandrakantyadwad

Can you please provide provide the source OFT file along with working sample code and snapshot of issue being reproduced on your end. Please also try using Aspose.Email for .NET 20.12 if you are using older version.

Attaching the source oft and fdm files.

OFT.zip (36.6 KB)

Attaching the screen shots of emails working vs not working

Email-Sent-Frm-Outlook.JPG (51.8 KB)

Email-Sent-With-Aspose.JPG (39.7 KB)

We are using the Aspose Java 20.12

@chandrakantyadwad

Can you please share the working sample code that we can use to verify and investigate the issue.

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

import com.aspose.email.License;
import com.aspose.email.MailAddress;
import com.aspose.email.MailAddressCollection;
import com.aspose.email.MailConversionOptions;
import com.aspose.email.MailMessage;
import com.aspose.email.MapiMessage;
import com.aspose.email.SmtpClient;

public class AsposeEmail {

	public static void main(String args[]) {
		SmtpClient client = null;
		try {
	    	String path = "myProps.properties";
	    	Properties props1 = new Properties();
	    	InputStream is =  new FileInputStream(new File(path));
			props1.load(is);
	    	
			
			String host  = props1.getProperty("host");
			System.out.println("host=>"+host);		
	
			String from  = props1.getProperty("from");
			System.out.println("from="+from);
			
			String to  = props1.getProperty("to");
			System.out.println("to="+to);
			
			String cc  = props1.getProperty("cc");
			System.out.println("cc="+cc);
			
			String sender  = props1.getProperty("sender");
			System.out.println("sender="+sender);
			
			String subject  = props1.getProperty("subject");
			System.out.println("subject="+subject);
			
			String oftFileName  = props1.getProperty("oftFileName");
			System.out.println("oftFileName="+oftFileName);
			
			String messageId  = props1.getProperty("messageId");
			System.out.println("messageId="+messageId);		
			
			String attachmentFileName  = props1.getProperty("attachmentFileName");
			System.out.println("messageId="+attachmentFileName);		
			
			String body  = props1.getProperty("body");
			System.out.println("body="+body);	
			
			String deliverNotification  = props1.getProperty("deliverNotification");
			System.out.println("deliverNotification="+deliverNotification);	
			

			License license = new License();
			license.setLicense("Aspose.Total.Java.lic");
			
			long start1 = System.currentTimeMillis();
			MapiMessage mapiMsg = MapiMessage.fromFile(oftFileName);
			System.out.println("before mapiMsg.getBody()=="+mapiMsg.getBody());
			long start = System.currentTimeMillis();
					
			mapiMsg.setBody(mapiMsg.getBody()+body);
			
			System.out.println("mapiMsg.getBody().length()=="+mapiMsg.getBody().length());
			
			long stop = System.currentTimeMillis();
			System.out.println("after mapiMsg.getBody()=="+mapiMsg.getBody());				
			System.out.println("time taken=="+( stop-start));

			
			//Convert MapiMessage to MailMessage keeping TNEF content intact
			MailConversionOptions options = new MailConversionOptions();
			options.setConvertAsTnef(true);		
			MailMessage mail = mapiMsg.toMailMessage(options);
			
			
			mail.setFrom(new MailAddress(from,from, false));
			
			if(sender != null && sender.length()>5) {
				mail.setSender(new MailAddress(sender, sender, true));	
			}		
			
			MailAddressCollection addressCollection = new MailAddressCollection();
			mail.setTo(addressCollection);
			mail.getTo().addMailAddress( new MailAddress(to,to, true));	
			
			if(cc != null && cc.length()>5) {
				mail.getCC().addMailAddress( new MailAddress(cc,cc, true));
			}
			
			mail.setSubject(subject);			
			
			//Custom MessageId
			mail.setMessageId(messageId);
									
			System.out.println("after mail.getBody()=="+mail.getBody());	
		
			client= new SmtpClient(host, 25);
		
			client.setUseTnef(true);
			client.send(mail);			
		
			System.out.println("time taken=="+( System.currentTimeMillis()-start1));
			System.out.println("===============Email sent out==============================");
			
		}catch(Exception e){
			e.printStackTrace();
		}finally {
		  client.close();
		}

	}
}

the sample body which the oft expects is something like:

Label1=Approve Credit 100;Label2=Approve Debit 100;Label3=Approve Loan 1000;

@chandrakantyadwad

I have created an issue with ID EMAILJAVA-34786 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.

Do you have an ETA when there will be any updated on this

@chandrakantyadwad

The issue has just recently been created in our issue tracking system and is pending for investigation in issues queue. We request for your patience and will share good news with you as soon as it will be addressed.

Any update on this please ? Our whole implementation to user Aspose Email api is dependent on this.

@chandrakantyadwad

I regret to share that at present the issue is still unresolved as it has been recently added in our issue tracking system. We request for your patience and will update you as soon as it will be resolved.

@chandrakantyadwad

We have investigated the issue internally on our end with Outlook(version 16) and Office365 Account. MS Outlook saves current custom field value to property “DyLabel61” before send.

After send/receive manually from Outlook, custom field value is not calculating by formula:

Mid( [Message] , Instr( [Message], “1=”)+2 , Instr([Message], “;”)- Instr([Message], “1=”) -2 )

The custom field value is loaded from property “DyLabel61” and we can test Outlook behaviour by deleting property “DyLabel61”. In case of Aspose SMTP send, property “DyLabel61” is not assigned but we can assign it using following code.

mapiMsg.addCustomProperty(MapiPropertyType.PT_UNICODE,
        "Approve Credit 100".getBytes(Charset.forName("utf-16le")), "DyLabel61");