Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Using Word I want to create a file including graphics to use in Em
I want to create a file with graphics and pictures which can then be read in
VB 2005 and put into an email by setting the message= to the content of that file. Said in another way. I want to use Word to create email message content full of pictures and so on and then save it for reading into a VB 2005 program and setting the message portion = to the file content. This code is working great for text files. Richtext files from word are not doing well with the pictures nor are HTML saves from WORD. I am using system.net.mail and the message is being set as mailmsg.body= to the content of the file read into a string variable. Should I just set the body equal to the file rather than making it into a string variable? Body appears to be a string type so this should work. I am setting the mailmsg.html to true so I would think it would decode correctly...but what do i know! Should the body be a type other than a string? perhaps this should just be an object but then will the mailmsg.body accept that variable type? What is the correct way to save this from Word so that it can be used as planned? Thank you. |
#2
Posted to microsoft.public.word.docmanagement,microsoft.public.word.vba.general
|
|||
|
|||
Using Word I want to create a file including graphics to use in Em
Coincidentally I have been working with fellow MVPs to produce a macro that
does something similar. The resulting code is: Sub Send_Extract_As_EMail() ' send the document in an Outlook Email message ' 2007 Graham Mayor, Tony Jollans, Doug Robbins ' & Sue Mosher Dim bStarted As Boolean Dim oOutlookApp As Outlook.Application Dim oItem As Outlook.MailItem Dim objDoc As Word.Document Dim strEMail As String strEMail = "PR_EMAIL_ADDRESS" 'Let the user choose the contact from Outlook 'And assign the email address to a variable strEMail = Application.GetAddress("", strEMail, _ False, 1, , , True, True) If strEMail = "" Then MsgBox "User cancelled or no address listed", , "Cancel" End If On Error Resume Next 'Get Outlook if it's running Set oOutlookApp = GetObject(, "Outlook.Application") 'Outlook wasn't running, start it from code If Err 0 Then Set oOutlookApp = CreateObject("Outlook.Application") bStarted = True End If 'Create a new mailitem Set oItem = oOutlookApp.CreateItem(olMailItem) Set objDoc = oItem.GetInspector.WordEditor Set objSel = objDoc.Windows(1).Selection With oItem .to = strEMail .Subject = InputBox("Subject?") Selection.Copy .Display objSel.Paste End With 'Clean up Set oItem = Nothing Set oOutlookApp = Nothing End Sub This will copy selected formatted text including in-line graphics and puts them in the body of an Outlook e-mail message. For me, it only works reliably when Outlook is already open - you can see the thread in the microsoft.public.word.vba.general group. Formatting in Word and the message body will be affected by the differing requirements of HTML and Word Document format. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org AWIcurrent wrote: I want to create a file with graphics and pictures which can then be read in VB 2005 and put into an email by setting the message= to the content of that file. Said in another way. I want to use Word to create email message content full of pictures and so on and then save it for reading into a VB 2005 program and setting the message portion = to the file content. This code is working great for text files. Richtext files from word are not doing well with the pictures nor are HTML saves from WORD. I am using system.net.mail and the message is being set as mailmsg.body= to the content of the file read into a string variable. Should I just set the body equal to the file rather than making it into a string variable? Body appears to be a string type so this should work. I am setting the mailmsg.html to true so I would think it would decode correctly...but what do i know! Should the body be a type other than a string? perhaps this should just be an object but then will the mailmsg.body accept that variable type? What is the correct way to save this from Word so that it can be used as planned? Thank you. |
#3
Posted to microsoft.public.word.docmanagement,microsoft.public.word.vba.general
|
|||
|
|||
Using Word I want to create a file including graphics to use i
Thank you for your input. I have used automation with Outlook in the past
but I am trying to move away from that. As i have been working with this there are two issues with a saved word document in HTML. 1. The graphic is not transfering and the email cannot find the graphic. What one sees is the typical frame where the picture goes with a caption name but no picture. Even with permission allowed to show the graphic, the graphic does not show up. Logically the graphic is not in the email so it needs a path to the graphic. But Word is not providing it. So the first issue is to get the graphic to be available to the email when being read. The second issue is that non printing characters are showing up as empty boxes in the email. Those boxes are typical of non mapped characters in a character set. I need them to be just plain white space. So is that an issue with the FONT I am using in the Word document or is it a problem for the recieving email software? They sure do not show in the original being read or worked on in Word. The characters printing boxes are space characters I think. It could also be a paragraph marker. Any way these have to go. This must be a common problem. I use Microsoft Word as my editor in Outlook for writing emails and none of these issues are a problem in writing and sending the emails. So there must be a solution. "Graham Mayor" wrote: Coincidentally I have been working with fellow MVPs to produce a macro that does something similar. The resulting code is: Sub Send_Extract_As_EMail() ' send the document in an Outlook Email message ' 2007 Graham Mayor, Tony Jollans, Doug Robbins ' & Sue Mosher Dim bStarted As Boolean Dim oOutlookApp As Outlook.Application Dim oItem As Outlook.MailItem Dim objDoc As Word.Document Dim strEMail As String strEMail = "PR_EMAIL_ADDRESS" 'Let the user choose the contact from Outlook 'And assign the email address to a variable strEMail = Application.GetAddress("", strEMail, _ False, 1, , , True, True) If strEMail = "" Then MsgBox "User cancelled or no address listed", , "Cancel" End If On Error Resume Next 'Get Outlook if it's running Set oOutlookApp = GetObject(, "Outlook.Application") 'Outlook wasn't running, start it from code If Err 0 Then Set oOutlookApp = CreateObject("Outlook.Application") bStarted = True End If 'Create a new mailitem Set oItem = oOutlookApp.CreateItem(olMailItem) Set objDoc = oItem.GetInspector.WordEditor Set objSel = objDoc.Windows(1).Selection With oItem .to = strEMail .Subject = InputBox("Subject?") Selection.Copy .Display objSel.Paste End With 'Clean up Set oItem = Nothing Set oOutlookApp = Nothing End Sub This will copy selected formatted text including in-line graphics and puts them in the body of an Outlook e-mail message. For me, it only works reliably when Outlook is already open - you can see the thread in the microsoft.public.word.vba.general group. Formatting in Word and the message body will be affected by the differing requirements of HTML and Word Document format. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org AWIcurrent wrote: I want to create a file with graphics and pictures which can then be read in VB 2005 and put into an email by setting the message= to the content of that file. Said in another way. I want to use Word to create email message content full of pictures and so on and then save it for reading into a VB 2005 program and setting the message portion = to the file content. This code is working great for text files. Richtext files from word are not doing well with the pictures nor are HTML saves from WORD. I am using system.net.mail and the message is being set as mailmsg.body= to the content of the file read into a string variable. Should I just set the body equal to the file rather than making it into a string variable? Body appears to be a string type so this should work. I am setting the mailmsg.html to true so I would think it would decode correctly...but what do i know! Should the body be a type other than a string? perhaps this should just be an object but then will the mailmsg.body accept that variable type? What is the correct way to save this from Word so that it can be used as planned? Thank you. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to create an email from mail merge including a hyperlink, so that the value of a merged field is included as part of the hyperlink URL, not just part of its text. | Mailmerge | |||
Word 2003 file size and graphics | Microsoft Word Help | |||
convert a PDF file including hyperlinks created in word | Microsoft Word Help | |||
how do I create custom labels with graphics? | Page Layout | |||
How do I create a mirror image of text and graphics for a t-shirt. | Microsoft Word Help |