Check whether mail item is proper for sending or not

D

Dhananjay

Hi,
I have added one button on ribbon viz. "Upload and Send" in ol 2007 /
vb 2005. When user will click on that button, I want to get
information about message like To, CC, body etc and upload that
information to web via web service & send it. But as uploading of mail
information is done before sending, if there are some problems while
sending like - "Could not resolve email address in To,CC" or problems
related to spell check etc, then I can not reverse the process of
uploading of mail.
Is there any way to check beforehand whether mail item is proper to
send or not? So that I could check this part before uploading.

Thanks,
D
 
D

Dmitry Streblechenko

Loop through all recipients in the MailItem.Recipients collecito nand check
if Recipient.Resolved = true.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
D

Dhananjay

Thanks Dmitry for your valuable reply, but could you please tell me
what should I do for Spell check, Signature issues. Since I want to
perform my upload and send operation synchronously, I realized that
with the check Recipient.Resolved, I managed issues related to
recipients but still spell check is happening after my upload.

Thanks in advance
 
D

Dmitry Streblechenko

To run spell check, read the Inspector.WordEditor property (returns
Word.Document object).
You can then call Document.CheckSpelling. Below is the function that I use
(Delphi):

//return true if the spelling does not have to be checked or if it was
checked successfully
function TMyAddin.TryCheckSpelling(Inspector: OleVariant): boolean;
var vDocument : OleVariant;
strKeyName : string;
v : integer;
begin
Result:=true; //everything is OK unless we find otherwise
with TRegistry.Create(KEY_READ) do begin
try
RootKey:=HKEY_CURRENT_USER;
strKeyName:=Format('Software\Microsoft\Office\%s.0\Outlook\Options\Spelling',
[IntToStr(fVersion)]); //DNL
if KeyExists(strKeyName) then begin
if OpenKey(strKeyName, false) then begin
//DNL
if ValueExists('Check') then begin
//DNL
v:=ReadInteger('Check');
if v <> 0 then begin
//yes, we must check the spelling
vDocument:=Inspector.WordEditor;
if (VarType(vDocument) = VarDispatch) and
(IDispatch(vDocument) <> nil) then begin
//at least we have the Word.Document object
vDocument.CheckSpelling;
if vDocument.SpellingErrors.Count > 0 then begin
//display a prompt if there are errors
if IDNO = MessageBox(GetForegroundWindow,
PChar(rsSpellingErrors), 'SalesLogix', MB_YESNO or MB_ICONWARNING or
MB_DEFBUTTON1) then begin //DNL
//do not send
Result:=false;
end;
end;
end;
end;
end;
end;
end;
finally
Free; //TRegistry
end;
end;
end;

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Thanks Dmitry for your valuable reply, but could you please tell me
what should I do for Spell check, Signature issues. Since I want to
perform my upload and send operation synchronously, I realized that
with the check Recipient.Resolved, I managed issues related to
recipients but still spell check is happening after my upload.

Thanks in advance
 
S

Sam Admin

Thanks again Dmitry for your reply and code!.

To run spell check, read the Inspector.WordEditor property (returns
Word.Document object).
You can then call Document.CheckSpelling. Below is the function that I use
(Delphi):

//return true if the spelling does not have to be checked or if it was
checked successfully
function TMyAddin.TryCheckSpelling(Inspector: OleVariant): boolean;
var vDocument : OleVariant;
    strKeyName : string;
    v : integer;
begin
  Result:=true; //everything is OK unless we find otherwise
  with TRegistry.Create(KEY_READ) do begin
    try
      RootKey:=HKEY_CURRENT_USER;
      strKeyName:=Format('Software\Microsoft\Office\%s.0\Outlook\Options\Spelling',
[IntToStr(fVersion)]);    //DNL
      if KeyExists(strKeyName) then begin
        if OpenKey(strKeyName, false) then begin
//DNL
          if ValueExists('Check') then begin
//DNL
            v:=ReadInteger('Check');
            if v <> 0 then begin
              //yes, we must check the spelling
              vDocument:=Inspector.WordEditor;
              if (VarType(vDocument) = VarDispatch) and
(IDispatch(vDocument) <> nil) then begin
                //at least we have the Word.Document object
                vDocument.CheckSpelling;
                if vDocument.SpellingErrors.Count > 0 then begin
                  //display a prompt if there are errors
                  if IDNO = MessageBox(GetForegroundWindow,
PChar(rsSpellingErrors), 'SalesLogix', MB_YESNO or MB_ICONWARNING or
MB_DEFBUTTON1) then begin   //DNL
                    //do not send
                    Result:=false;
                  end;
                end;
              end;
            end;
          end;
        end;
      end;
    finally
      Free;  //TRegistry
    end;
  end;
end;

--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

Thanks Dmitry for your valuable reply, but could you please tell me
what should I do for Spell check, Signature issues. Since I want to
perform my upload and send operation synchronously, I realized that
with the check Recipient.Resolved, I managed issues related to
recipients but still spell check is happening after my upload.

Thanks in advance

Loop through all recipients in the MailItem.Recipients collecito nand
check
if Recipient.Resolved = true.
 
N

Nic

Dhananjay,

I'm starting with a similar project. I don't suppose you'll be willing to share some code with me???

If so you can contact me on mailto:[email protected]

Under certain conditions I need to intercept a message and stream it to a web application....

Nic



Sam Admin wrote on Tue, 05 January 2010 06:0
Thanks again Dmitry for your reply and code!.

To run spell check, read the Inspector.WordEditor property (returns
Word.Document object).
You can then call Document.CheckSpelling. Below is the function that I use
(Delphi):

//return true if the spelling does not have to be checked or if it was
checked successfully
function TMyAddin.TryCheckSpelling(Inspector: OleVariant): boolean;
var vDocument : OleVariant;
    strKeyName : string;
    v : integer;
begin
  Result:=true; //everything is OK unless we find otherwise
  with TRegistry.Create(KEY_READ) do begin
    try
      RootKey:=HKEY_CURRENT_USER;
      strKeyName:=Format('Software\Microsoft\Office\%s.0\Outlook\O ptions\Spelling',
[IntToStr(fVersion)]);    //DNL
      if KeyExists(strKeyName) then begin
        if OpenKey(strKeyName, false) then begin
//DNL
          if ValueExists('Check') then begin
//DNL
            v:=ReadInteger('Check');
            if v <> 0 then begin
              //yes, we must check the spelling
              vDocument:=Inspector.WordEditor;
              if (VarType(vDocument) = VarDispatch) and
(IDispatch(vDocument) <> nil) then begin
                //at least we have the Word.Document object
                vDocument.CheckSpelling;
                if vDocument.SpellingErrors.Count > 0 then begin
                  //display a prompt if there are errors
                  if IDNO = MessageBox(GetForegroundWindow,
PChar(rsSpellingErrors), 'SalesLogix', MB_YESNO or MB_ICONWARNING or
MB_DEFBUTTON1) then begin   //DNL
                    //do not send
                    Result:=false;
                  end;
                end;
              end;
            end;
          end;
        end;
      end;
    finally
      Free;  //TRegistry
    end;
  end;
end;

--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

Thanks Dmitry for your valuable reply, but could you please tell me
what should I do for Spell check, Signature issues. Since I want to
perform my upload and send operation synchronously, I realized that
with the check Recipient.Resolved, I managed issues related to
recipients but still spell check is happening after my upload.

Thanks in advance

Loop through all recipients in the MailItem.Recipients collecito nand
check
if Recipient.Resolved = true.
--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Hi,
I have added one button on ribbon viz. "Upload and Send" in ol 2007 /
vb 2005. When user will click on that button, I want to get
information about message like To, CC, body etc and upload that
information to web via web service & send it. But as uploading of mail
information is done before sending, if there are some problems while
sending like - "Could not resolve email address in To,CC" or problems
related to spell check etc, then I can not reverse the process of
uploading of mail.
Is there any way to check beforehand whether mail item is proper to
send or not? So that I could check this part before uploading.
Thanks,
D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top