locked
Sending mail from Windows store app RRS feed

  • Question

  • Hi,

    I need to send email from my Windows Store app to a predefined mail id and with a text(which user can edit).

    For this purpose I am using mailto:abc@xyz.com?subject=mno&body=pqrs

    this is working fine and opening Mail app (if it is default app for mailto).

    But there is a issue, body in Mail app is populated with truncated text if the body text is too large.

    So is there any limit when opening mail using this option and if yes how could I resolve it.


    Himanshu Nigam

    Thursday, January 9, 2014 8:56 AM

Answers

All replies

  • Hi Himanshu,

    Windows will truncate your URI after a 2,083 characters (see this MSDN article). Since you can't exceed this limit, there are two options:

    1. Use the Share contract and export your text using this method.
    2. Use a web or cloud service to send your e-mail

    --
    Kind regards,
    Christian

    Thursday, January 9, 2014 12:43 PM
  • If you don't want to use the share charm you could copy the body text to the clipboard and then do something like

    mailto:abc@xyz.com?subject=mno&body=Press ctrl v to paste message.

    Thursday, January 9, 2014 1:13 PM
  • mailto: body size does have a limit (everything has limits correct).  You can test this yourself to see what that limit is by seeing where it is truncated.  I don't know of any way to workaround this.

    You may be able to get around this entirely by using the Share Contract.  Not knowing your entire situation makes it difficult to comment however.


    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Thursday, January 9, 2014 1:21 PM
    Moderator
  • If you don't want to use the share charm you could copy the body text to the clipboard and then do something like

    mailto:abc@xyz.com?subject=mno&body=Press ctrl v to paste message.

    This won't solve the problem! URIs in Windows have a maximum length of 2,083 characters, regardless which method is used to create the URI. By the way, letting the user build his own mailto-URI is not very user-friendly.
    Thursday, January 9, 2014 1:31 PM
  • If you don't want to use the share charm you could copy the body text to the clipboard and then do something like

    mailto:abc@xyz.com?subject=mno&body=Press ctrl v to paste message.

    This won't solve the problem! URIs in Windows have a maximum length of 2,083 characters, regardless which method is used to create the URI. By the way, letting the user build his own mailto-URI is not very user-friendly.
    The literal string "Press ctrl v to paste message." does not exceed 2083 characters. The user would not be building their own uri. Wherever the user enters the email body in the app it would be programmatically transferred to the clipboard and the user, when the mail client opens, would then press ctrl v as instructed to paste it as the message body. This as a workaround if using the share charm is not desired.
    Thursday, January 9, 2014 1:53 PM
  • Hi Peter,

    this might work, but that's a very dirty workaround and still not user-friendly at all! I advise against doing this.

    --
    Kind regards,
    Christian

    Thursday, January 9, 2014 2:03 PM
  • Realize that the mailto: protocol is no real substitute for an actual SMTP (Mail) message.  Your best bet would be to use MIME based messaging through an SMTP 3rd party library if you wish to sent a lot of data via email.

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)


    Thursday, January 9, 2014 2:04 PM
    Moderator
  • Realize that the mailto: protocol is no real substitute for an actual SMPT (Mail) message.  Your best bet would be to use MIME based messaging through an SMPT 3rd party library if you wish to sent a lot of data via email.

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    I guess you mean SMTP (Simple Mail Transfer Protocol). It's a true fact: There's a library for that called Mail.dll for Windows Store. However, you need to include your account credentials in your code, which is very vulnerable.
    Thursday, January 9, 2014 2:14 PM
  • Hi All,

    Thanks everyone for such a prompt response.

    Since there is text limitation with mailto, so I have decided to use Share charm. But on opening I want it prepopulated with a defined email id.

    Can this be achieved in any way ?

    Thanks in advance


    Himanshu Nigam

    Friday, January 10, 2014 7:06 AM