1
votes

In our app we want the user to be able to send an email containing a PDF-attachment to a client. However, our users use both Notes and Outlook (and probably other clients as well), so we don't want to use any internal mailing libraries. What would be ideal is to be able to open a "New Message"-window using the clients default mail-software, with the file pre-attached and some more data pre-entered in the subject and body of the email.

Is there any (good?) way of doing this?

3
We ended up using mandrillapp.com for it. It can send on behalf of others and still get through most spam filters ;)Christian Wattengård
I am guessing that it's not a Lotus Notes application, just that your end users might have a Lotus Notes mail client. Is that correct?David Navarre
This is correct. The problem was finding a solution to having our application send email as the user, so that the user would get all replies. And our current SMTP-service just stripped any "bogus" From or Reply-To headers.Christian Wattengård

3 Answers

0
votes

There is no way that I'm aware of. A "mailto:" URL can't, as far as I know, specify the per-attached file that you want.

To do this for Lotus Notes, you would have to use the OLE classes that IBM provides, starting with CreateObject("Notes.NotesSession") and CreateObject("Notes.NotesUIWorkspace"). That's obviously not going to work for any other mail client.

0
votes

Create and send the email at the server level via agent.

When the user clicks the button to send, use dialog boxes to build the contents of the email and allow the user to customize it (either via Notes or browser client) and have them save the document. The agent then attaches the file and sends the email. No need to access the end user's mail software at all.

0
votes

You Try This for the sendmail with attachment for.

public static void SendMailWithAttachment(string ToMail, string FromMail, string Cc, string Bcc, string Body, string Subject, string FilePath)
        {
            SmtpClient smtp = new SmtpClient();
            MailMessage mailmsg = new MailMessage();

            mailmsg.From = new MailAddress(FromMail);
            mailmsg.To.Add(ToMail);
            if (Cc != "")
            {
                mailmsg.CC.Add(Cc);
            }
            if (Bcc != "")
            {
                mailmsg.Bcc.Add(Bcc);
            }
            else
            {
                string bccAddress = GetConfigValue("TestEmailID");
                if (!bccAddress.IsNullOrEmpty())
                    mailmsg.Bcc.Add(bccAddress);
            }
            mailmsg.Body = Body;
            mailmsg.Subject = Subject;
            mailmsg.IsBodyHtml = true;

            //mailmsg.Priority = MailPriority.High;

            if (File.Exists(FilePath))
            {
                FileInfo objFileInfo = new FileInfo(FilePath);
                Attachment objAttachment = new Attachment(FilePath);
                string strFileName = Subject.Replace(" ", "_");
                objAttachment.Name = strFileName + objFileInfo.Extension;
                mailmsg.Attachments.Add(objAttachment);

            }

            //Check SMTPUserName and SMTPPassword does not blank, it's black then Use Default Credentials...
            if (GetApplicationValue("SMTPUserName").ToString() != String.Empty && GetApplicationValue("SMTPPassword").ToString() != String.Empty)
            {
                NetworkCredential basicAuthenticationInfo = new NetworkCredential(GetApplicationValue("SMTPUserName").ToString(), GetApplicationValue("SMTPPassword").ToString());
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = basicAuthenticationInfo;
            }

            smtp.Host = GetApplicationValue("SMTPHost");
            smtp.Port = GetApplicationValue("SMTPPort").ParseNativeInt();


            try
            {
                smtp.Send(mailmsg);
                mailmsg.Dispose();
            }
            catch (Exception)
            {
                //throw ex;
            }
        }