Outlook code for both plain text and html format - vb.net

Some people advice that it is good idea to sent an e-mail in both format html and plain text together in the same e-mail body as following link explains.
https://litmus.com/blog/reach-more-people-and-improve-your-spam-score-why-multi-part-email-is-important
You can see four code options below.
.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
.BodyFormat = Outlook.OlBodyFormat.olFormatPlain
.BodyFormat = Outlook.OlBodyFormat.olFormatRichText
.BodyFormat = Outlook.OlBodyFormat.olFormatUnspecified
You are able to select one option as following picture shows.
http://www.rocketseed.com/wp-content/uploads/2013/07/Outlook-2010-HTML.jpg
How to sent mixed formatted e-mails even your code must include one option?
I need vb.net code for this.

That link does not apply to Outlook: when a message is saved (or sent) all 3 flavors of the message body (plain, HTML, RTF) are synchronized. You cannot send a message from Outlook with either flavor out of sync. You can send plain text messages, html/plain, or RTF (winmail.dat), but you cannot send with plain text body out of sync of the HTML body.

Related

Remove automatically generated signature in copied body of previous mail, from body of mail

I create new mail, fill body and send it.
A VBA macro automatically creates a second email with same body and resends. The second mail has two signatures, one in body in line and one on the end of email.
Problem is, how to remove the first automatic signature in the second email.
.HTMLBody = objMail.Body & vbNewLine & vbNewLine
but everything is in one line:
TEXT TEXT TEXT. Name, Surname, Address, Phone, etc.
My goal is remove signature from HTML body and add signature to end of email.
TEXT TEXT TEXT
signature
Name
Surename
Address
etc
When signature is disabled via user, it works perfectly.

MS Access | How to get content from mail body to table?

I am working on a project where I need to get ms access table/data from mail body and execute some command in SAP. I can manage SAP part but issue is that how to get information from mail body. i tried linking my mailbox in access but it shows me all mail body text but i need some specified contents only. example
Hello,
Please supplement budget
WBS Amt
N.10002077.001 1
from above what i need is just "N.10002077.001" and "1" ,but how to get that information only in table is the issue?
Further, what I will get in my mail will be table with 2 column but access imports it as a simple text.
It is impossible to give a definite answer to your question because it is too vague but it is possible to get you started.
Have a look at this answer of mine: https://stackoverflow.com/a/12146315/973283. The question is not relevant other than the OP did not understand that showing screenshots told us little about what the body looked like to a VBA macro. The answer includes a macro that copies selected properties from every email in Inbox to an Excel worksheet. This will allow you to see what an email’s body looks like to a VBA macro.
How will you identify the emails from which you wish to extract data? The two simple choices are:
Look at every email in a folder and identify the interesting one by examining the subject, sender or some other property.
Select the interesting emails then run a macro which uses ActiveExplorer to access the selected emails.
The answer referenced above demonstrates technique 1. There are lots of answers demonstrating technique 2 but I can add an example macro if necessary.
An email typically has an Html body and a text body. If an email has an Html body, that is the one shown to the user. A macro can access either or both. Your screen shot looks like a text body although appearances can be deceptive. If it is a text body, the email does not have an Html body.
If it is a text body, the layout of the body is probably something like:
Hello,{cr}{lf}
Please supplement budget{cr}{lf}
WBS{tab}{tab}{tab}{tab}{tab}Amt{cr}{lf}
N.10002077.001{tab}{tab}1{cr}{lf}
This assumes, the sender has used variable numbers of tabs to line up the columns.
You could use Split on vbCr & vbLf to convert the string body into an array of strings with one line per array entry. Discard lines up to and including the line starting “WBS” then process each line down to any signature. Split each line on vbTab and expect to find two entries with values with the rest blank.
See how far you can get with the above hints then clarify your answer if you need more information.

Excel textbox formated text to Htmlbody convert

I need to send text from Excel textbox with HTMLBODY. So when i send it as
.HTMLBody = ThisWorkbook.Worksheets("info").Shapes("TextBox 1").TextFrame2.TextRange.Characters.Text
Email comes without formating.
So how to convert textbox to Html source? Or how to get data from html file to .HTMLBody?
Ron de Bruin's website has some great stuff on sending HTML emails. Look on this page for the RangetoHTML function.

How to replace text in the body of an Outlook email message

I have text data that I read from a file; I need to place it in the body of an email message. There are about 50 such data items to be placed into existing text.
It seems I should be able to put a marker (dataItem1, dataItem2, etc.) and replace that with the matching text data from the file.
Searches only turn up replacing field data such as Recipient, Subject, etc., or replacing the entire body. Would I have to generate the entire body in the code? Seems like I should be able to "insert" a data item into existing body text.
Any suggestions will be much appreciated.
Just in case your email is formatted as HTML, and you don't want to lose the formatting, here's what you want to do.
myMessage.HTMLBody = Replace(myMessage.HTMLBody, "dataItem1", "replacement item")
Use the Body property of the MailItem you're working with. Assign it to a variable and you can edit it:
Dim body As String
body = myMessage.Body
body = Replace(body,"dataItem1","your replacement here")
Then assign the variable to the Body:
myMessage.Body = body

Outlook 2007 vsto send email with HTML content

I am developing the addin for the outlook 2007 using VSTO. One of the function is to capture the send event, then force convert the email format to HTML and then insert a link to the bottom of the email message content. Following is my code to convert the email content to html format:
mailItem.BodyFormat = OlBodyFormat.olFormatHTML;
string link = generateLink();
mailItem.Body += link;
However, when the email was recevied, it is not appear in the HTML format
What's wrong with the above code for making email as HTML?
Thank ~~
Patrick
You have to set mailItem.HTMLBody instead of mailItem.Body to use HTML.